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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top