geoutils.Raster.crop#
- Raster.crop(bbox, inplace=False)#
Crop the raster to a given extent.
Match-reference: a reference raster or vector can be passed to match bounds during cropping.
Cropping preserves the original pixel resolution, cropping to the extent that most closely aligns with the current coordinates. To match the extent of another dataset exactly, use reproject().
- Parameters:
bbox (
TypeVar(RasterType, bound= RasterBase) |TypeVar(VectorType, bound= Vector) |list[float] |tuple[float,...]) – Geometry to crop raster to. Can use either a raster or vector as match-reference, or a list of coordinates. Ifbboxis a raster or vector, will crop to the bounds. Ifbboxis a list of coordinates, the order is assumed to be [xmin, ymin, xmax, ymax].inplace (
bool) – (DEPRECATED. Use rast = rast.crop() instead) Whether to crop in-place or not.
- Return type:
- Returns:
A new cropped raster.