eo_forge.utils.raster_utils.clip_raster
- eo_forge.utils.raster_utils.clip_raster(raster, bbox, enable_transform=True, close=False, crop=True, nodata=0, all_touched=True, filled=True, hard_bbox=False)
Clip raster to provided BBox. If enable_transform
- Parameters
- raster: rasterio dataset
Input raster.
- bbox: Geopandas Dataframe.
Region of Interest.
- crop: bool
Whether to crop the raster to the extent of the roi_bbox.
- close: bool
Close the input raster dataset before returning the clipped raster.
- enable_transform: bool
Allows coordinate reference system transformations if the target BBox’s crs and the raster crs differ.
- nodata: float
No data value.
- all_touched: boolean
If True, all pixels touched by geometries will be included. If false, only pixels whose center is within the polygon are included.
- filled: boolean
If True, the pixels outside the features will be set to nodata. If False, the output array will contain the original pixel data, and only the mask will be based on shapes. Defaults to True.
- hard_bbox: bool
If True, adjust the extent of raster to match the BBox. Otherwise, leave the raster’s original shape and mask the values outside the bbox.
- Returns
- clipped raster: opened rasterio.MemoryFile