我正在尝试绘制我拥有的一组坐标所在的县。我希望代码遍历每个坐标,检查它所在的县,然后打印相应的县。但是,当前在空闲状态下运行时,光标只是闪烁,似乎没有任何反应。任何有关我的代码可能出错的地方的帮助将不胜感激。我不确定代码是否正确检查县或是否可以从 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)