classmethod Regions.from_geodataframe(df, *, name=None, source=None, overlap=None)

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

  • 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 True mask_3D will ensure overlapping regions are correctly assigned to grid points while mask 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.