I am trying to extract country borders between two points, using Python. The border is a Shapely Polygon.exterior or LinearRing, the start and end points are Shapely Points.
My idea is the following:
Get the closest points or projections for both points along the border
These points split the border into two splines (or LineStrings). Select the shorter one, based on length (ideally reprojected to meters, but it might be overkill).
Decide if the first and/or the last point of the selected spline is needed, to avoid zig-zag like splines at the ends. The given start and end points must be included in the final spline.
Calculated border is: start_point + calculated_spline + end_point
So far I'm a bit stuck with the following concepts:
Shapely doesn't support projection on LinearRing, only LineString. How can I calculate the closest points efficiently on a LinearRing? I believe projection isn't needed, as I'll be selecting whether to keep the end points in step 3. Should I just loop over all points of the LinearRing and select the closest one?
How can I split a LinearRing into two LineStrings, based on two of their points?
Is it true that when comparing relative segment lengths of a LinearRing, I can just measure their length in WGS84?
When I have the LineString, should I use
.projectfor deciding weather the endpoints should be included, to avoid zig-zag like splines?