'Geopandas dissolve error: GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing

I have a geopandas dataframe that looks like the following

gdf.head()
    geometry                                            raster_val  diss
0   POLYGON ((2.50553 49.10338, 2.50553 49.09506, ...   33.299999   1
1   POLYGON ((2.50553 49.09506, 2.50553 49.08673, ...   33.790001   1
2   POLYGON ((2.52218 49.09506, 2.52218 49.08673, ...   34.000000   1
3   POLYGON ((2.14760 49.07009, 2.14760 49.06176, ...   33.180000   1
4   POLYGON ((2.02274 49.06176, 2.02274 49.05344, ...   33.459999   1

I am trying to dissolve the POLYGONS based on the column diss

gdf_diss = gdf.dissolve(by='diss')

but I get the following error:

GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing


Solution 1:[1]

TL;DR - create a new environment, you likely installed something that bumped a version that made GEOS freak out.

This happened to me when I installed PyGEOS to take advantage of sjoin_nearest, requiring PyGEOS>0.10. I think I did that with pip which was a bad idea. I also install Cython and then networkx-metis with pip in a conda environment. I saw a few other posts outside of Stack Overflow about being an issue with the GEOS installation. Creating a new conda environment - including with Cycthon and networkx-metis - worked for me.

As for the root cause, I don't know.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1