xdem.DEM.crop#
- DEM.crop(bbox, mode='match_pixel', *, inplace=False)#
- Overloads:
self (RasterType), bbox (RasterType | gu.Vector | list[float] | tuple[float, …]), mode (Literal[‘match_pixel’] | Literal[‘match_extent’]), inplace (Literal[False]) → RasterType
self (RasterType), bbox (RasterType | gu.Vector | list[float] | tuple[float, …]), mode (Literal[‘match_pixel’] | Literal[‘match_extent’]), inplace (Literal[True]) → None
self (RasterType), bbox (RasterType | gu.Vector | list[float] | tuple[float, …]), mode (Literal[‘match_pixel’] | Literal[‘match_extent’]), inplace (bool) → RasterType | None
Crop the raster to a given extent.
Match-reference: a reference raster or vector can be passed to match bounds during cropping.
Reprojection is done on the fly if georeferenced objects have different projections.
- Parameters:
bbox (
TypeVar(RasterType, bound= Raster) |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].mode (
Literal['match_pixel'] |Literal['match_extent']) – Whether to match within pixels or exact extent.'match_pixel'will preserve the original pixel resolution, cropping to the extent that most closely aligns with the current coordinates.'match_extent'will match the extent exactly, adjusting the pixel resolution to fit the extent.inplace (
bool) – Whether to update the raster in-place.
- Returns:
A new raster (or None if inplace).