我有n个坐标点,从这些点创建了一个多边形,现在如果一个坐标点在这个多边形中,我该如何找到它距离多边形的垂直距离?
coords = [(45.888106581826065, 8.512891340789281), (45.89087605100282, 8.51131888355673), (45.89242907135495, 8.51043574866833), (45.88810733356788, 8.512894063368899), (45.890876868519385, 8.51132182341189), (45.892063379278696, 8.510647148893547), (45.89243094789967, 8.510442653438174), (45.88811958097381, 8.512938419782168), (45.89088904461223, 8.51136560966078), (45.89207575921023, 8.510692030810025), (45.89244290698806, 8.51048665710127), (45.88813186579548, 8.512982911786311), (45.89090145183551, 8.511410227156235), (45.89245416375836, 8.510528076647585), (45.88813271861146, 8.512986000437545), (45.89090242476677, 8.511413725908412), (45.89245495631277, 8.510530992872562)]
需要检查是否在多边形内部的点:
p2 = Point(45.88831, 8.51283)
检查坐标点(p2
)是否在多边形内:
poly = MultiPoint(coords).convex_hull
if p2.within(poly):
print("Givien point is in polygon")
我尝试使用 boundary.distance
函数来计算距离,结果得到的是4.7144012366024
,但不确定这是否是垂直距离或其他什么距离!
print(poly.boundary.distance(p2))
#output: 4.71440123660249
有人能帮我获取离该点垂直的距离吗?