matplotlib路径包含带纬度/经度的点

2024-10-02 00:30:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用matplotlib路径。包含\u点对顶点和点使用纬度/经度。在

我需要对lat/lon对进行某种转换才能正常工作吗?这个例子似乎很好用,但我想确保我在所有情况下都能正确使用。在

如果我需要改造,怎么做?在

def point_in_poly(vertices, x, y)
    from matplotlib.path import Path as mpPath

    path =mpPath(vertices)
    point = (x,y)
    return path.contains_point(point)

vertices = [(146.0,-42.0),(147.0,-42.0),(147.0,-43.0), (146.0,-43.0)]
print(point_in_poly(vertices, 146.5, -42.5)

谢谢


Tags: pathin路径matplotlib情况例子pointlon

热门问题