python 查找多边形上最近点的坐标

    from shapely.geometry import Polygon, Point, LinearRing

    poly = Polygon([(0, 0), (2, 8), (14, 10), (6, 1)])

    point = Point(12, 4)

    pol_ext = LinearRing(poly.exterior.coords)  # 根据线,做一个环

    d = pol_ext.project(point)  # 返回沿该几何图形到最接近指定点的点的距离,如果归一化参数为True,则返回归一化为线性几何长度的距离。

    p = pol_ext.interpolate(d)  # 沿线性几何图形返回指定距离处的点, 如果超出则认为是最长距离的点

    closest_point_coords = list(p.coords)[0]

 

posted on 2022-03-07 10:56  闹不机米  阅读(395)  评论(0编辑  收藏  举报

导航