Reputation: 29
In a shapely MultiLineString, I have LineStrings that may be disjointed. What is the best way of connecting it?
I have attached an image example, where I need the blue line to be connected to the start of the orange.
I have thought about finding the shortest distance between the end node of the disjointed linestring and the start node of other linestrings but not sure how to implement it.
Any help is appreciated! Thank you.
Upvotes: -1
Views: 36
Reputation: 1516
Check out the nearest_points function. You can convert the 2 points returned to a new line, and then use union_all to merge the three lines together...
Upvotes: 1