odc.geo.xr.ODCExtension.crop
- ODCExtension.crop(poly: Geometry, apply_mask: bool = True, all_touched: bool = True) XrT
Crops and optionally mask an
xarray.Datasetorxarray.DataArrayto the spatial extent of a geometry.- Parameters:
xx (
TypeVar(XrT,DataArray,Dataset)) –DatasetorDataArray.poly (
Geometry) – Aodc.geo.geom.Geometrypolygon used to cropxx.apply_mask (
bool) – Whether to mask out pixels outside of the rasterized extent ofpolyby setting them toNaN.all_touched (
bool) – IfTrueandapply_mask=True, the rasterize step will burn in all pixels touched bypoly. IfFalse, only pixels whose centers are within the polygon or that are selected by Bresenham’s line algorithm will be burned in.
- Return type:
- Returns:
A
DatasetorDataArraycropped and optionally masked to the spatial extent ofpoly.
See also