I have a GeoPandas dataframe with a.o. polygons as 'geometry' column and a corresponding value in a different column. E.g. like such:
import numpy as np
import geopandas as gpd
xmin, xmax, ymin, ymax = 900000, 1080000, 120000, 280000
xc = (xmax - xmin) * np.random.random(2000) + xmin
yc = (ymax - ymin) * np.random.random(2000) + ymin
gdf = gpd.GeoDataFrame(geometry=gpd.points_from_xy(xc,yc),crs=3857)
gdf['geometry'] = gdf['geometry'].buffer(5000)
gdf['value'] = np.random.random(2000)
gdf.head()
geometry value
0 POLYGON ((1058397.021 237842.681, 1058372.944 ... 0.792110
1 POLYGON ((907562.671 276549.404, 907538.595 27... 0.124436
2 POLYGON ((953685.557 229083.936, 953661.481 22... 0.264356
3 POLYGON ((1052030.845 242915.680, 1052006.769 ... 0.161183
4 POLYGON ((1063942.060 263330.293, 1063917.983 ... 0.972290
What I would like to do is create new polygons describing the overlap of all polygons and sum the values of these overlapping polygons, as in the picture below:
I've looked at dissolve and at unary_union, but these do not seem to do the trick. Any suggestions are appreciated.
