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.
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).
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.