4

I am trying to buffer points which are quite close together, and then dissolve the overlapping buffer polygons into larger polygons. After doing the buffer is where I have the issue. I have tried using dissolve('geometry') but that gives this error.

KeyError: 'geometry' 

I think the proper way to do this is using unary_union but my output is a multipolygon and I cant use it.

gdf2 = gpd.read_file(SELECT)
gdf2b = gdf2.buffer(gridDist)
gdfu = gdf2b.unary_union
gdfu.plot()

AttributeError: 'MultiPolygon' object has no attribute 'plot'

Or if I try to send the unary_union to a file

gpd.GeoSeries.to_file(gdf3u, BUFF1, driver="ESRI Shapefile")

AttributeError: 'MultiPolygon' object has no attribute 'index'

So my question is how can I either dissolve these polygons based on their self intersecting geometry and have the result be a geodataframe or a geoseries? Or how can I transform the multipolygon I have from into a geodataframe?

Plot of buffered points

1 Answer 1

4

Put the geometry into a new GeoDataFrame, that's what has the .plot() method.

new = gpd.GeoDataFrame(crs=gdf2.crs, geometry=[gdfu])
new.plot()

then you can write out the new object

new.to_file('path/to/file')
1
  • Thanks So Much! I know this is simple but I couldnt find how to make a geodataframe from geometry in the geopandas documentation! It should be right up there with geodataframe.from_file
    – JakeGIS
    Commented Jun 7, 2018 at 20:28

Your Answer

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

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