I try to merge two Shapely Objects in my Python Project.
There is a sort of kind of manual that describes some features of Shapely such as cascaded_union()
but I that only works for Polygons. The shapely.ops.unary_union()
method should work for other geometries as well but I can't get it to work.
In a nutshell: how do I merge 2 LinearRing Objects?
I actually solved the problem myself.
p1 = Polygon(ring.coords)
p2 = Polygon(ring2.coords)
to make polygons from my rings. then I create an array with those polygons. merge them with cascaded_union and create a LinearRing from the new polygon.
pols = [p1, p2]
new_pol = ops.cascaded_union(pols)
new_ring = LinearRing(new_pol.exterior.coords)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With