ODCExtension.mask(poly: Geometry, invert: bool = False, all_touched: bool = True) XrT

Apply a polygon geometry as a mask, setting all xarray.Dataset or xarray.DataArray pixels outside the rasterized polygon to NaN.

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

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

  • invert (bool) – Whether to invert the mask before applying it to xx. If True, only pixels inside of poly will be masked.

  • all_touched (bool) – If 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)


A Dataset or DataArray masked by poly.