I have multiple polygon in one shapefile. I want to check if a polygon intersects with another polygon or not. Right now i am taking one polygon and checking with all the polygon in the shapefile if they intersect or not. This process is slow as there are polygon that doesnot intersect and i dont want to check them. Is there any faster way to check if the polygon intersect with each other avoiding polygon that are far away.
import shapely
import geopandas as gpd
from shapely.geometry import Polygon
shapefile = gpd.read_file("polygon.shp")
for i in range(1,100):
print(i)
p1 = shapefile["geometry"][0]
p2 = shapefile["geometry"][i]
if p1.intersects(p2)== True:
print("True")
else:
print("false")
sindex.query_bulk