I have been trying to find two closest points between two polygons. Initially I used the "nearest_points" shapely function. However this does not always return a point on each of the polygon edges. e.g. In case poly2 is enclosed in poly1, point1 and point2 are the same point on poly2.

points = nearest_points(poly1,poly2)
point1 = np.array(points[0])
point2 = np.array(points[1])

I have attempted to convert the polygon object to a LinearRing object of the outer coordinates, hoping it would "forget" about the interior when using the nearest_points calculation. However the problems remains the same. There seem to be solutions for point to polygon edge: https://stackoverflow.com/questions/33311616/find-coordinate-of-closest-point-on-polygon-shapely

Was wondering in case anybody has any suggestion for shapely functions to use, or if I need to code something manually to find a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.