API reference

This page provides an auto-generated summary of regionmask’s API.

Top-level functions

mask_geopandas(geodataframe, lon_or_obj[, ...])

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

mask_3D_geopandas(geodataframe, lon_or_obj)

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

from_geopandas(geodataframe, *[, numbers, ...])

Create regionmask.Regions from a geopandas.GeoDataFrame.

flatten_3D_mask(mask_3D)

flatten 3D masks

plot_3D_mask(mask_3D, **kwargs)

flatten and plot 3D masks

set_options(**kwargs)

Set options for regionmask in a controlled context.

get_options()

Get options for regionmask.

Regions

Creating Regions

Regions(outlines[, numbers, names, abbrevs, ...])

class for plotting regions and creating region masks

Mapping Number/ Abbreviation/ Name

Regions.map_keys(key)

map from names and abbrevs of the regions to numbers

Selecting

Regions.__getitem__(key)

subset of Regions or Region

Plotting

Regions.plot(*[, ax, projection, add_label, ...])

plot region on cartopy axes

Regions.plot_regions(*[, ax, add_label, ...])

plot regions on regular axes

Creating a Mask

Regions.mask(lon_or_obj[, lat, lon_name, ...])

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

Regions.mask_3D(lon_or_obj[, lat, drop, ...])

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

Conversion

Regions.to_dataframe()

Convert this region into a pandas.DataFrame, excluding polygons.

Regions.to_geodataframe()

Convert this region into a geopandas.GeoDataFrame.

Regions.to_geoseries()

Convert this region into a geopandas.GeoSeries.

Regions.from_geodataframe(df, *[, name, ...])

Convert a geopandas.GeoDataFrame created with to_geodataframe back to regionmask.Region (round trip)

Attributes

Regions.abbrevs

list of abbreviations of the regions

Regions.names

list of names of the regions

Regions.numbers

list of the numbers of the regions

Regions.region_ids

dictionary that maps all names and abbrevs to the region number

Regions.polygons

list of shapely Polygon/ MultiPolygon of the regions

Regions.centroids

list of the center of mass of the regions

Regions.bounds

list of the bounds of the regions (min_lon, min_lat, max_lon, max_lat)

Regions.bounds_global

global bounds over all regions (min_lon, min_lat, max_lon, max_lat)

Regions.lon_180

if the regions extend from -180 to 180

Regions.lon_360

if the regions extend from 0 to 360

_OneRegion

Creating one Region

_OneRegion(number, name, abbrev, outline)

a single Region, used as member of Regions

Attributes

_OneRegion.coords

numpy array of the region

_OneRegion.bounds

bounds of the regions (Multi)Polygon.bounds (min_lon, min_lat, max_lon, max_lat)

Private Functions

core.utils._wrapAngle360(lon)

wrap angle to [0, 360[.

core.utils._wrapAngle180(lon)

wrap angle to [-180, 180[.

core.utils._wrapAngle(lon[, wrap_lon, ...])

wrap the angle to the other base

core.utils._is_180(lon_min, lon_max[, msg_add])