regionmask.Regions.from_geodataframe
- classmethod Regions.from_geodataframe(df, *, name=None, source=None, overlap=None)
Convert a
geopandas.GeoDataFrame
created withto_geodataframe
back toregionmask.Region
(round trip)- Parameters:
- dfgeopandas.GeoDataFrame
GeoDataFrame to be transformed to a Regions class.
- namestr, optional
name of the Regions. If None uses
df.attrs.get("name", "unnamed")
.- sourcestr, optional
Source of the shapefile. If None uses
df.attrs.get("source")
.- overlapbool, default: None
Indicates if (some of) the regions overlap. If None uses
df.attrs.get("overlap")
. If Truemask_3D
will ensure overlapping regions are correctly assigned to grid points whilemask
will error (because overlapping regions cannot be represented by a 2D mask).If False 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.
- Returns:
- regionmask.core.regions.Regions