How to combine 2 Shapely objects?

I am trying to combine two Shapely Objects in my Python project. There is a kind of manual that describes some Shapely functions, such as cascaded_union cascaded_union() but I work only for polygons. The shapely.ops.unary_union() method should work for other geometries too, but I can't get it to work.

In a nutshell: how to combine 2 LinearRing objects?

+8
python merge shapely
source share
1 answer

I myself solved the problem.

 p1 = Polygon(ring.coords) p2 = Polygon(ring2.coords) 

make polygons from my rings. then I create an array with these polygons. combine them with cascaded_union and create LinearRing from the new polygon.

 pols = [p1, p2] new_pol = ops.cascaded_union(pols) new_ring = LinearRing(new_pol.exterior.coords) 
+6
source share

All Articles