clip_by_polygon#
- geowombat.clip_by_polygon(data, df, query=None, mask_data=False, expand_by=0)#
Clips a DataArray by vector polygon geometry.
- 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_by_polygon(ds, df, query="Id == 1")