Check if geo-point is inside or outside of polygon

前端 未结 3 1126
刺人心
刺人心 2020-12-23 17:19

I am using python and I have defined the latitudes and longitudes (in degrees) of a polygon on the map. My goal is to check if a generic point P of coordinates

3条回答
  •  滥情空心
    2020-12-23 17:47

    There is also an emerging python library turfpy. which is used for geospatial analysis.

    PyPI

    Github

    Example:

    from turfpy.measurement import boolean_point_in_polygon
    from geojson import Point, Polygon, Feature
    
    point = Feature(geometry=Point((-46.6318, -23.5523)))
    polygon = Polygon(
        [
            [
                (-46.653, -23.543),
                (-46.634, -23.5346),
                (-46.613, -23.543),
                (-46.614, -23.559),
                (-46.631, -23.567),
                (-46.653, -23.560),
                (-46.653, -23.543),
            ]
        ]
    )
    boolean_point_in_polygon(point, polygon)
    

提交回复
热议问题