lair.geo.clip#

lair.geo.clip(data, bbox=None, extent=None, geom=None, crs='EPSG:4326', **kwargs)[source]#

Clip the data to the given bounds.

Note

The result can be slightly different between supplying a geom and a bbox/extent. Clipping with a geom seems to be exclusive of the outer bounds, while clipping with a bbox/extent seems to be inclusive of the outer bounds.

Parameters:
  • data (xr.DataArray | xr.Dataset) – The data to clip.

  • bbox (tuple[minx, miny, maxx, maxy]) – The bounding box to clip the data to.

  • extent (tuple[minx, maxx, miny, maxy]) – The extent to clip the data to.

  • geom (shapely.Polygon) – The geometry or geometries to clip the data to.

  • crs (Any, optional) – The CRS of the input geometries. Default is ‘EPSG:4326’.

  • kwargs (Any) – Additional keyword arguments to pass to the rioxarray clip method.

Returns:

xr.DataArray | xr.Dataset – The clipped data.

Return type:

DataArray | Dataset