2

I have a GeoPandas dataframe like the following one

f,ax=plt.subplots()
gdf.boundary.plot(ax=ax)

enter image description here

I would like to merge/dissolve the adjacent polygons.

gdf2 = gpd.geoseries.GeoSeries([geom for geom in gdf.unary_union.geoms])

but I get an error

GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing

If I check the validity of the geometries I get:

for i in gdf.index:
    print(gdf['geometry'][i].exterior.type)

LinearRing
LinearRing
LinearRing
LinearRing
LinearRing

and:

all(gdf.geometry.is_valid)
True
7
  • You want three rows as a result?
    – Bera
    Commented Mar 31, 2021 at 12:40
  • @BERA yes exaclty
    – emax
    Commented Mar 31, 2021 at 12:40
  • 1
    @BERA if I check I get all(gdf.geometry.is_valid) True
    – emax
    Commented Mar 31, 2021 at 12:45
  • 1
    Can you share the data in some form? Your code should work. Commented Mar 31, 2021 at 14:11
  • @martinfleis I am sharing with you a similar data for which I get the same error drive.google.com/drive/folders/…
    – emax
    Commented Mar 31, 2021 at 14:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.