How can i find the closest perimeter point from a given point on any edge of a polygon?

How can I find the closest edge point to a given point X, where X is a point either on the edge or at a vertex of a polygon? There are lots of answers and ways of finding this for points inside polygons, but I'm looking to find an answer for edge to edge.

2 Examples:

1. I want to find the closest point on the polygon perimeter from vertex E
2. I want to find the closest point on the polygon perimeter from random point on the DE line.

Note: neither of the closest points in this example are on the same edge as either of the two points given, but easily could be in another example.

I'm currently using the Shapely python library for all of my other calculations, but cannot seem to find any way to get to this kind of solution.

• The closest point on the perimeter to vertex E is vertex E. There must be some additional condition you're leaving out. Feb 12, 2019 at 16:31
• Hmm. I'm trying to think of another way to explain the condition. The closest point that is not the same point, and not on the same line. But it could be the next vertex. So the closest point to point C would be point D Feb 12, 2019 at 16:40
• If point B did not exist, then closest point to the red dot between D and E would be vertex E Feb 12, 2019 at 16:40
• Remove the segment the point is laying on (the two segments if it is a vertex). Draw the circle to the nearest remaining vertex, and find the closest point on the intersection of the segments with the circle.
– N74
Feb 12, 2019 at 17:57

• Building on this comment, because I was using Shapely I was able to do convert my polygon into a LineString and then do the following: line.interpolate(line.project(point)). Getting the length of the line is all that's left. Thanks! Feb 12, 2019 at 19:03