From Open Foris Wiki

Jump to: navigation, search

PointsToSquares.py - converts XY-locations into 100 x 100 m squares in a kml-file

Conversion of user-defined plot centre points in a text file into squares of 100 x 100 m in kml format. These squares are training data collection locations, meant to be used with a specific tool made for Google Earth.

Usage: PointsToSquares.py <input> <output> <UTM zone number> <ID> <X-field> <Y-field>


PointsToSquares.py indata.txt locations.kml 36 1 5 6 


Input textfile projection needs to be UTM South WGS84 zones. Output kml is in latlon WGS84.


  • Get Example data set
  • For this exercise following tools are used: PointsToSquares.py, gdalinfo
    • Either use your own .txt file consisting of three columns: <ID> <X-field> <Y-field> or
    • Generate it by using oft-gengrid.bash

  • Open your working directory using
cd /home/...
  • In this exercise we use the .txt file derived from oft-gengrid.bash called training.txt. This is how the first 10 rows look like:
head training.txt
  • NOTE, that the projection is UTM South WGS84 zones. In our case it is UTM Zone 20S.
  • How to find out? Before running oft-gengrid.bash, check the projection of the input image (landsat_t1.tif), which is the base to calculate training.txt using
gdalinfo landsat_t1.tif          //part of output: PROJCS["WGS 84 / UTM zone 20S"
  • After generating training.txt run the command line for calculating your points to 100 x 100x meter squares, creating an kml outputfile called Points2Squares_training.kml:
 PointsToSquares.py training.txt Points2Squares_training.kml 20 1 2 3  //20 refers to our UTM Zone, nr 1-3 refer to the columns in our input file training.txt

  • Load your result Points2Squares_training.kml e.g. in GoogleEarth
  • Check if the individual square is 100 x 100 meter!

Back to Open Foris Toolkit Main Page

Back to Tools & Exercises

Personal tools