world2pixel
gis.util.world2pixel(gtf, x, y)
Calculate the pixel location based on coordinates.
(Thanks to the ogr cookbook!)
Parameters
Name | Type | Description | Default |
---|---|---|---|
gtf | tuple | The geotransform of a grid dataset. Has the following shape: (left, xres, xrot, upper, yrot, yres). | required |
x | float | int | The x coordinates of a point | required |
y | float | int | The y coordinates of a point | required |
Returns
Name | Type | Description |
---|---|---|
tuple | Row and column indices. |
Examples
# Load a dataset
= fiat.fio.GridSource(<some raster file>)
gs # Get the geotransform
= gs.geotransform
gtf # Calculate the indices
= world2pixel(gtf, <x>, <y>) row, col