我正在尝试将我所拥有的一组坐标映射到哪个县。我希望代码遍历每个坐标,检查它所在的县,然后打印相应的县。但是,目前在空闲时运行光标只是闪烁,似乎没有任何事情发生。任何有关我的代码可能出错的帮助将不胜感激。我不确定代码是否正确检查各县,或者它是否可以从shapefile中获取各县的名称?
import pysal as ps
from ast import literal_eval
COUNTIES = '/Users/JoshuaHawley/Desktop/counties/English Ceremonial Counties.shp'
shps = ps.open(COUNTIES)
counties = shps.read()
f = open('/Users/JoshuaHawley/sundayCoordinates.txt').read()
seq = literal_eval(f.replace("\n", ","))
coordinates = seq[0:]
for line in coordinates:
points = coordinates[:2]
NotFound = True
while NotFound == True:
if coordinates in counties:
NotFound = False
name_of_county = counties.getNamePolygon()
print(name_of_county)