lair.geo.BaseGrid.clip#

BaseGrid.clip(bbox=None, extent=None, geom=None, crs=None, inplace=False, **kwargs)[source]#

Clip the data to the given bounds.

Note

A cell is kept when its center is inside the bounds or on them, with a bbox, an extent or a geom, whichever way the coordinates run. With a geom the cells outside it stay in the grid as NaN; see lair.geo.clip().

Parameters:
  • 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 to clip the data to.

  • crs (Any) – The CRS of the input geometries. If not provided, the CRS of the data is used.

  • inplace (bool, optional) – Whether to modify the data in place. Default is False (returns a new copy with the clipped data).

  • kwargs (Any) – Additional keyword arguments for bbox and extent, passed to the rioxarray clip_box method; none are taken with geom.

Returns:

BaseGrid – The clipped grid

Return type:

Self

See also

clip

The same for xarray data.