odc.geo.xr.ODCExtension.mask

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.

Parameters:
  • 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)

Returns:

A Dataset or DataArray masked by poly.