odc.geo.xr.crop

odc.geo.xr.crop(xx, poly, apply_mask=True, all_touched=True)[source]

Crops and optionally mask an xarray.Dataset or xarray.DataArray to the spatial extent of a geometry.

Parameters:
  • xx (TypeVar(XrT, DataArray, Dataset)) – Dataset or DataArray.

  • poly (Geometry) – A odc.geo.geom.Geometry polygon used to crop xx.

  • apply_mask (bool) – Whether to mask out pixels outside of the rasterized extent of poly by setting them to NaN.

  • all_touched (bool) – If True and apply_mask=True, the rasterize step will burn in all pixels touched by poly. If False, only pixels whose centers are within the polygon or that are selected by Bresenham’s line algorithm will be burned in.

Return type:

TypeVar(XrT, DataArray, Dataset)

Returns:

A Dataset or DataArray cropped and optionally masked to the spatial extent of poly.