regionmask.Regions

class regionmask.Regions(outlines, numbers=None, names=None, abbrevs=None, name='unnamed', source=None)

class for plotting regions and creating region masks

__init__(self, outlines, numbers=None, names=None, abbrevs=None, name='unnamed', source=None)
Parameters
outlinesiterable or dict of: Nx2 array of vertices, Polygon or MultiPolygon

List of the coordinates of the vertices (outline) of the region as shapely Polygon/ MultiPolygon or list.

numbersiterable of int, optional

List of numerical indices for every region. Default: range(0, len(outlines))

namesiterable or dict of string, optional

Long name of each region. Default: [“Region0”, .., “RegionN”]

abbrevsiterable or dict of string, optional

Abbreviations of each region. Default: [“r0”, …, “rN”]

namestring, optional

Name of the collection of regions. Default: “unnamed”

sourcestring, optional

Source of the region definitions. Default: “”.

Methods

__init__(self, outlines[, numbers, names, …])

Parameters

combiner(self, prop)

combines attributes from single regions

map_keys(self, key)

map from names and abbrevs of the regions to numbers

mask(self, lon_or_obj[, lat, lon_name, …])

create a grid as mask of a set of regions for given lat/ lon grid

plot(self[, ax, proj, regions, add_label, …])

plot map with with region outlines

plot_regions(self[, ax, regions, add_label, …])

plot map with with srex regions

Attributes

abbrevs

list of abbreviations of the regions

bounds

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

bounds_global

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

centroids

list of the center of mass of the regions

coords

list of coordinates of the region vertices as numpy array

lon_180

if the regions extend from -180 to 180

lon_360

if the regions extend from 0 to 360

names

list of names of the regions

numbers

list of the numbers of the regions

polygons

list of shapely Polygon/ MultiPolygon of the regions

region_ids

dictionary that maps all names and abbrevs to the region number