Skip to content Skip to sidebar Skip to footer

Point-in-polygon, Simple 4 Vertex Polygon, No External Libraries

I'm plotting things on a map with matplot lib and have an atlas of coordinates, I have a 4 vertex set of points that define a boundary on the map, I want to clear all entries in my

Solution 1:

Untested, but this should work if you then use inboundspoints to plot points instead of atlas_data - note the contains_points if statement doesn’t have not any more:

border= [(-35.2825, 149.108), (-35.2873, 149.118), (-35.2714, 149.118), (-35.2758, 149.127)]
border_path= Path(border, codes=None, closed=True)
inboundspoints = []
# Atlas data is defined in another part. contains [name, lat, lon]
for n, i in enumerate(atlas_data):
    lat_lon = (i[1], i[2])

    if border_path.contains_points([lat_lon], transform=None):
        inboundspoints.append( atlas_data[n] )

Post a Comment for "Point-in-polygon, Simple 4 Vertex Polygon, No External Libraries"