explode_to_polygons#
- caf.cvt.data_cleaning.explode_to_polygons(gdf, track_part=False)[source]#
Explodes the MultiPolygons and GeomCollections in a GeoDataFrame into Polygons.
Converts rows in a GeoDataFrame with a MultiPolygon or GeometryCollection geometry into multiple rows with Polygon geometries, adding a ‘part’ column to keep track of how many new rows have been created for each if specified. Leaves other geometries as they are, and preserves the original CRS.
- Parameters:
gdf (gpd.GeoDataFrame) – The input GeoDataFrame that needs to be cleaned
track_part (bool = False) – True if tracking the parts of each extracted polygon is necessary, False if not.
- Returns:
A new GeoDataFrame containing only Polygon geometries, with a new column ‘part’ to keep track.
- Return type:
gpd.GeoDataFrame