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): field = loads(layer.GetGeometryRef().ExportToWkb()) 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.