windkit.spatial.clip
- windkit.spatial.clip(obj, mask, all_touched=False, invert=False, nodata=None, **kwargs)[source]
Clip object to mask.
Clipping returns an object that has been reduced to the requested shape. Dropping data that falls outside of the masked region.
- Parameters:
obj (geopandas.GeoDataFrame, xarray.DataArray or xarray.Dataset) – Object with raster-like dimensions to clip with mask.
mask (geopandas.GeoDataFrame or BBox) – Geometric features to clip out of object.
all_touched (bool) – raster or cuboid only: Include all pixels touched by the mask? False inclodes only those that pass through the center. Passed to rasterio.features.geometry_mask. Defaults to False.
invert (bool) – raster or cuboid only: If true values outside of the mask will be nulled, if False values inside the mask are nulled. Opposite is passed to rio.features.geometry_mask. Defaults to False.
nodata (float) – raster or cuboid only: If no data is not None, all masked data will be filled with this value. Default, masked data is set to NaN.
kwargs (dict) – Other keyword-arguments are passed to the underlying function, depending on the type of object.
- Returns:
Object of the same type as obj clipped by geometric features.
- Return type:
See also
Notes
This function behaves the opposite of rasterio.features.geometry_mask by default, in that it nulls areas outside of the area of interest rather than inside. For rasters, when the mask edges intersects with the cell centers they are not guaranteed to be included. It is recommend to use a buffer or all_touched=True to be sure.