regionmask.mask_3D_geopandas
- regionmask.mask_3D_geopandas(geodataframe, lon_or_obj, lat=None, *, drop=True, lon_name=None, lat_name=None, numbers=None, method=None, wrap_lon=None, overlap=False, use_cf=None)
create a 3D boolean mask of a set of regions for the given lat/ lon grid
- Parameters:
geodataframe (GeoDataFrame or GeoSeries) – Object providing the region definitions (polygons).
lon_or_obj (object or array_like) – Can either be a longitude array and then
lat
needs to be given. Or an object where the longitude and latitude can be retrieved from, either using cf_xarray or by the names “lon” and “lat”. See alsouse_cf
.lat (array_like, optional) – If
lon_or_obj
is a longitude array, the latitude needs to be passed.drop (boolean, default: True) – If True (default) drops slices where all elements are False (i.e no gridpoints are contained in a region). If False returns one slice per region.
lon_name (str, optional) – Deprecated. Name of longitude in
lon_or_obj
, default: “lon”.lat_name (str, optional) – Deprecated. Name of latgitude in
lon_or_obj
, default: “lat”numbers (str, optional) – Name of the column to use for numbering the regions. This column must not have duplicates. If None (default), takes
geodataframe.index.values
.method (“rasterize” | “shapely” | “pygeos”. Default: None) – Deprecated. Backend used to determine whether a gridpoint lies in a region. All backends lead to the same mask. If None autoselects the backend.
wrap_lon (bool | 180 | 360, optional) – Whether to wrap the longitude around, inferred automatically. If the regions and the provided longitude do not have the same base (i.e. one is -180..180 and the other 0..360) one of them must be wrapped. This can be achieved with wrap_lon:
None
: autodetects whether the longitude needs to be wrappedFalse
: nothing is done. This is useful when working with coordinates that are not in lat/ lon format.True
: longitude data is wrapped to [0, 360[ if its minimum is smaller than 0 and wrapped to [-180, 180[ if its maximum is larger than 180.180
: Wraps longitude coordinates to [-180, 180[360
: Wraps longitude coordinates to [0, 360[
overlap (bool, default: False) – Indicates if (some of) the regions overlap. If True
mask_3D_geopandas
will ensure overlapping regions are correctly assigned to grid points.If False (default) assumes non-overlapping regions. Grid points will silently be assigned to the region with the higher number (this may change in a future version).
There is (currently) no automatic detection of overlapping regions.
use_cf (bool, default: None) – Whether to use
cf_xarray
to infer the names of the x and y coordinates. If None uses cf_xarray if the coord names are unambigous. If True requires cf_xarray if False does not use cf_xarray.
- Returns:
mask_3D (boolean xarray.DataArray)
See also
References
See https://regionmask.readthedocs.io/en/stable/notebooks/method.html