windkit.spatial.mask

windkit.spatial.mask(obj, mask, all_touched=False, invert=False, nodata=None, **kwargs)[source]

Mask WindKit object with geometric mask.

Masking an object returns the same object with values outside of the masked region filled with NaN.

Parameters:
  • obj (xarray.Dataset,xarray.DataArray) – WindKit object to mask.

  • mask (geopandas.GeoDataFrame or BBox) – Mask to mask object by.

  • all_touched (bool) – raster or cuboid only: Include all pixels touched by the mask? False includes 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.

Returns:

Clipped WindKit object.

Return type:

same as obj

See also

clip

Note

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.