geodata.mask.crop_raster

geodata.mask.crop_raster#

geodata.mask.crop_raster(raster: rasterio.DatasetReader, bounds: tuple[float, float, float, float], lat_lon_bounds: bool = True) rasterio.DatasetReader#

Crop a raster given geographical coordinates or its array index bounds

Parameters:
  • raster (ras.DatasetReader) – An opened rasterio tif dataset.

  • bounds (tuple[float, float, float, float]) – Geographical coordinates or array index bounds.

  • lat_lon_bounds (bool) – If True (by default), the bounds tuple are latitude-longitude coords input.

Returns:

The cropped raster.

Return type:

ras.DatasetReader