3

I have two Polygons which intersect along one edge as shown below.

enter image description here

I need to add the red vertices at each end of the intersection to the blue polygon. I thought I could do this with by calling union on the Polygon and the LineString produced by intersection of the two polygons but it appears not.

Is there a way of doing what I need to do?

Jamie Bull
  • 349
  • 1
  • 4
  • 14

1 Answers1

2

You can use the properties of union (and unary_union) witch split all the lines at intersections (Planar graph)

enter image description here

# LinearRing of the polygons
ringgreen = LineString(list(polygreen.exterior.coords))
ringblue  = LineString(list(polyblue.exterior.coords))
# Union of the rings
union = ringgreen.union(ringblue)
# now polygonize the result
from shapely.ops import polygonize
result = [geom for geom in polygonize(union]

enter image description here

and

enter image description here

gene
  • 54,868
  • 3
  • 110
  • 187
  • That's actually just a less-roundabout way of doing what I was already doing. Thanks to your post confirming what is supposed to happen, I've found that I was getting tripped up by the fact I was translating my polygons first, then trying to do the union step. That was then failing because of floating point errors. – Jamie Bull Apr 08 '16 at 11:06