0

I have two shapes which are adjacent as in image A below. How can I add the left-hand red point to the blue polygon (poly1) and the right-hand red point to the grey polygon (poly2)? The idea is that both shapes will then share a line segment defined by those two points.

A) adjacent shapes

I can find the LineString which is the intersection by calling poly1.intersection(poly2) but I don't know how to add the missing point or points (as would be required in the situation below in image B).

B)enter image description here

Jamie Bull
  • 12,889
  • 15
  • 77
  • 116

1 Answers1

0

I think the correct answer is to use union, although if there is anything I'm missing I'd be happy to hear it.

poly1 = wkt.loads("POLYGON((1 1,2 1,2 2,1 2,1 1))")
poly2 = wkt.loads("POLYGON((1.5 2,2.5 2,2.5 3,1.5 3,1.5 2))")

shared_line = poly1.intersection(poly2)
poly1 = poly1.union(shared_line)
poly2 = poly2.union(shared_line)
Jamie Bull
  • 12,889
  • 15
  • 77
  • 116