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:
df (geopandas.GeoDataFrame) – GeoDataFrame to be transformed to a Regions class.
name (str, optional) – name of the Regions. If None uses
df.attrs.get("name", "unnamed")
.source (str, optional) – Source of the shapefile. If None uses
df.attrs.get("source")
.overlap (bool, 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