regionmask.Regions.from_geodataframe
- classmethod Regions.from_geodataframe(df: GeoDataFrame, *, name: str | None = None, source: str | None = None, overlap: bool | None = None)
Convert a
geopandas.GeoDataFramecreated withto_geodataframeback 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 | None, default: None
Indicates if (some of) the regions overlap and determines the behaviour of the
maskmethods.If True
mask_3Densures overlapping regions are correctly assigned to grid points, whilemaskraises an Error (because overlapping regions cannot be represented by a 2 dimensional mask).If False assumes non-overlapping regions. Grid points are silently assigned to the region with the higher number.
If None (default) checks if any gridpoint belongs to more than one region. If this is the case
mask_3Dcorrectly assigns them andmaskraises an Error.
- Returns:
- regionmask.core.regions.Regions