regionmask.Regions.mask

Regions.mask(lon_or_obj, lat=None, lon_name='lon', lat_name='lat', method=None, wrap_lon=None)

create a 2D boolean mask of a set of regions for the given lat/ lon grid

Parameters
  • 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 retrived as: lon = lon_or_obj[lon_name] and lat = lon_or_obj[lat_name]

  • lat (array_like, optional) – If lon_or_obj is a longitude array, the latitude needs to be specified here.

  • lon_name (str, optional) – Name of longitude in lon_or_obj, default: “lon”.

  • lat_name (str, optional) – Name of latgitude in lon_or_obj, default: “lat”

  • method (“rasterize” | “shapely” | “pygeos”. Default: None) – Method used to determine whether a gridpoint lies in a region. All methods lead to the same mask. If None (default) autoselects the method.

  • 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 wrapped

    • False: 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[

Returns

mask_2D (boolean xarray.DataArray)

References

See https://regionmask.readthedocs.io/en/stable/notebooks/method.html