0

I have a GeoPandas dataframe that looks like the following

    geometry                                            raster_val
0   POLYGON ((1.85626 49.12003, 1.85626 49.11171, ...   28.530001
1   POLYGON ((1.87290 49.12003, 1.87290 49.11171, ...   28.930000
2   POLYGON ((1.88123 49.12003, 1.88123 49.11171, ...   28.670000
3   POLYGON ((1.89788 49.12003, 1.89788 49.11171, ...   28.510000
4   POLYGON ((1.90620 49.12003, 1.90620 49.11171, ...   29.969999

that I can show

f,ax=plt.subplots(figsize=(8,8))
gdf.plot(column='raster_val', scheme='quantiles', legend=True, ax=ax)

enter image description here

I would like to cluster all the adjacent polygons with a given values and create macropolygons based on such aggregration. Let say I want to create macropolygons that have raster_val > 33

0

2 Answers 2

1

You can get macro-polygons by creating bins from the raster value column with pandas cut and then dissolve on the new binned column with geopandas dissolve.

0

Select polygons where GeoDataFrame's raster values greater than 33

macropolygons  = gdf[gdf['raster_val'] > 33]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.