为什么要花点时间检查点是否为形状?

时间:2019-06-03 13:54:50

标签: python shapefile

我大约有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")

测试打印显示正在进行大量计算,但是循环不会结束。对于如此少量的坐标和形状,我相信这与我的代码有关。

0 个答案:

没有答案