replace geometry within geodataframe with the union of geometries

Viewed 263

I am trying to replace existing geometry of polygon by merging with neighboring polygon.

new_gdf -> geodataframe containing polygons

r -> rings of type polygon to be merged with polygons

union -> could be polygon or multipolygon

new_gdf = gdf.copy(deep=True)

for r in list(rings):
    for i in range(0, len(new_gdf)):
        if new_gdf.iloc[i][10].intersects(r):
            new_gdf.at[i, 'geom'] = unary_union([new_gdf.iloc[i][10], r])
            break

This is giving me error Must have equal len keys and value when setting with an iterable but couldn't find out what could be the reason and how to solve that.

0 Answers
Related