# Find out points outside the polygon

I have a shapefile with geometries of different regions. Also I have a list of coordinate points(field_lonlat), I want to consider only those points of the list which are outside the polygon geometries using python. Below is my code to check it but trying to find a simpler version of it.

``````from osgeo import ogr
from shapely.geometry import Point
from shapely.prepared import prep
from shapely.wkb import loads
import json
g = ogr.Open("Polygons.shp")
points = []
for layer in g.GetLayer(0):
fieldP = prep(field)
for x,y in field_lonlat: //field_lonlat is my list of points
item = Point(x, y)
if fieldP.contains(item):
pass
else:
points.append((x,y))
``````

But my points list checks for a single polygon once and hence considers only those points which are not in it but which might be inside an another polygon.

I think this would make slightly more sense :

``````from osgeo import ogr
from shapely.geometry import Point
from shapely.prepared import prep
from shapely.wkb import loads
import json

g = ogr.Open("Polygons.shp")
list_to_remove = []
points = field_lonlat[:] # make a copy of the list
for x,y in field_lonlat:
item = Point(x,y)
for layer in g.GetLayer(0):
• I came up with the same idea but : if multiple points are inside one polygone, the `break` only remove the first point. And for a more Pythonic writing : `points = field_lonlat.copy()`. Aug 27, 2020 at 12:16
• in the `points` list we remove every single points that are inside one/multiple of the polygons. So at the end we end up with a list contained only the points that have been found to NOT be inside any of the polygons Aug 27, 2020 at 13:24