我大约有1000个坐标和3000个形状。我的目标是查看坐标是否在每种形状内:
import pandas as pd
import shapefile
from shapely.geometry import Point, shape
coords = pd.read_csv("coords.csv")
areas = shapefile.Reader("./areas")
shapes = areas.shapes()
for a, b in zip(coords["a"], coords["b"]):
for i in shapes:
if (Point((a, b)).within(shape(i))):
print("in shape")
测试打印显示正在进行大量计算,但是循环不会结束。对于如此少量的坐标和形状,我相信这与我的代码有关。