I have a dataframe in GeoPandas Python. The data frame contains around 3800 rows (geometry type is Multiplygon). Some polygons are overlapping each other. I want to dissolve those overlap. I used following code to dissolve overlapping polygons.
import geopandas as gpd
overlapping_areas = gdf[gdf.geometry.overlaps(gdf.unary_union)]
if not overlapping_areas.empty:
dissolved_coverage = gdf.dissolve(by='LEGEND')
dissolved_coverage = dissolved_coverage.reset_index()
else:
dissolved_coverage = gdf
where gdf is the GeoPandas dataframe and 'LEGEND' is one of the columns in GeoPandas dataframe that contains the unique values.
The above code has been running for more than two hours (still running as I write). I am not sure how long further it takes to compelte the execution. Is there any better way to program it faster?