Point inside polygon

后端 未结 1 1256
庸人自扰
庸人自扰 2020-12-11 15:50

I\'m looking for a way to determine whether a particular point is within a polygon given its vertices using NumPy/SciPy.

I haven\'t been able to find one online. Is

相关标签:
1条回答
  • 2020-12-11 16:02

    Have you considered Shapely? Just create a Polygon and check if polygon contains a point.

    >>> from shapely.geometry import Point
    >>> from shapely.geometry.polygon import Polygon
    
    >>> point = Point(0.5, 0.5)
    >>> polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
    >>> polygon.contains(point)
    True
    >>> point2 = Point((10, 10))
    >>> polygon.contains(point2)
    False
    
    0 讨论(0)
提交回复
热议问题