How can I calculate mean latitude and mean longitude of each block from a geotiff
image separating it into regular blocks (say, 50 by 50 pixels).
The input data is just the imagery,for example as downloaded from: http://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_2048.tif
This can be opened into python using gdal as folows:
import gdal
geotiff = gdal.Open ('land_shallow_topo_2048.tif')
colum_numbers,row_numbers,band_numbers=geotiff.RasterXSize,
geotiff.RasterYSize,geotiff.RasterCount
print (colum_numbers,row_numbers,band_numbers)
2048 1024 3
Take a look at this question: Obtain Latitude and Longitude from a GeoTIFF File
Since your image is already in lat-lon coordinates, the following values should be in lat-lon:
Now the size of a pixel is:
The center of a 50x50 box that is
i
box rows andj
box columns away from the corner is:If you are using some other coordinate system, you can achieve a similar result by doing the transformation from the other, similar, question.