我试图地理编码一个CSV文件,其中包含位置的名称和一个解析出的地址,其中包括地址号码,街道名称,城市,邮政编码,国家。我想通过GEOPY使用GEOPY和ArcGIS地理代码,我想创建一个代码,循环通过5000多个条目的csv,并在csv中的单独列中给出纬度和经度。我想通过Geopy使用ArcGIS地理编码服务。有人能给我一个开始的代码吗?谢谢!
这是我的剧本:
import csv
from geopy.geocoders import ArcGIS
geolocator = ArcGIS() # here some parameters are needed
with open('C:/Users/v-albaut/Desktop/Test_Geo.csv', 'rb') as csvinput:
with open('output.csv', 'w') as csvoutput:
output_fieldnames = ['Name','Address', 'Latitude', 'Longitude']
writer = csv.DictWriter(csvoutput, delimiter=',', fieldnames=output_fieldnames)
reader = csv.DictReader(csvinput)
for row in reader:
# here you have to replace the dict item by your csv column names
query = ','.join(str(x) for x in (row['Name'], row['Address']))
Address, (latitude, longitude) = geolocator.geocode(query)
# here is the writing section
output_row = {}
output_row['Name'] = Name
output_row['Address'] = Address
output_row['Latitude'] = Latitude
output_row['Longitude'] =Longitude
writer.writerow(output_row)
目前没有回答
相关问题 更多 >
编程相关推荐