regionmask.Regions.from_geodataframe

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)

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 mask methods.

  • If True mask_3D ensures overlapping regions are correctly assigned to grid points, while mask raises 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_3D correctly assigns them and mask raises an Error.

Returns:
regionmask.core.regions.Regions