geoutils.Raster.xy2ij

Contents

geoutils.Raster.xy2ij#

Raster.xy2ij(x, y, op=<class 'numpy.float32'>, precision=None, shift_area_or_point=None)[source]#

Get indexes (row,column) of coordinates (x,y).

By default, the indexes are shifted with the interpretation of pixel coordinates “AREA_OR_POINT” of the raster, to ensure that the indexes of points represent the right location. See parameter description of shift_area_or_point for more details.

This function is reversible with ij2xy for any pixel interpretation.

Parameters:
  • x (Union[Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]]) – X coordinates.

  • y (Union[Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]]) – Y coordinates.

  • op (type) – Operator to compute index.

  • precision (float | None) – Precision passed to rasterio.transform.rowcol().

  • shift_area_or_point (bool | None) – Whether to shift with pixel interpretation, which shifts to center of pixel indexes if self.area_or_point is “Point” and maintains corner pixel indexes if it is “Area” or None. Defaults to True. Can be configured with the global setting geoutils.config[“shift_area_or_point”].

Returns i, j:

Indices of (x,y) in the image.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[Union[floating[Any], integer[Any]]]], ndarray[tuple[Any, ...], dtype[Union[floating[Any], integer[Any]]]]]