clip#

geowombat.clip(data, df, query=None, mask_data=False, expand_by=0)#

Clips a DataArray by vector polygon geometry.

Deprecated since version 2.1.7: Use geowombat.clip_by_polygon().

Parameters:
  • data (DataArray) – The xarray.DataArray to subset.

  • df (GeoDataFrame or str) – The geopandas.GeoDataFrame or filename to clip to.

  • query (Optional[str]) – A query to apply to df.

  • mask_data (Optional[bool]) – Whether to mask values outside of the df geometry envelope.

  • expand_by (Optional[int]) – Expand the clip array bounds by expand_by pixels on each side.

Return type:

DataArray

Returns:

xarray.DataArray

Examples

>>> import geowombat as gw
>>>
>>> with gw.open('image.tif') as ds:
>>>     ds = gw.clip(ds, df, query="Id == 1")
>>>
>>> # or
>>>
>>> with gw.open('image.tif') as ds:
>>>     ds = ds.gw.clip(df, query="Id == 1")