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
gs = fiat.fio.GridSource(<some raster file>)
# Get the geotransform
gtf = gs.geotransform
# Calculate the indices
row, col = world2pixel(gtf, <x>, <y>)