pixel2world

gis.util.pixel2world(gtf, x, y)

Calculate coordinates based on pixel location.

(Thanks to the ogr cookbook!)

Parameters

Name Type Description Default
gtf tuple The geotransform of a grid dataset. Can be optained via the get_geotransform method. Has the following shape: (left, xres, xrot, upper, yrot, yres). required
x int Column number of the pixel required
y int Row number of the pixel required

Returns

Type Description
tuple Return the x, y coordinates of the upper left corner of the cell.

Examples

# Load a dataset
gs = fiat.io.GridSource(<some raster file>)
# Get the geotransform
gtf = gs.get_geotransform()
# Calculate the coordinates
x, y = pixel2world(gtf, <column>, <row>)
Back to top