Geopy と ArcGIS を使用して複数の住所をジオコーディングしようとしています。CSV をループして住所と名前を確認し、緯度と経度の座標に別の列を提供するようにコードを設定しました。
これは、実行時にコードに問題があり、緯度経度座標を提供せず、CSV を適切にループしません。複数の住所をループしてジオコーディングし、緯度と経度の座標を与えるにはどうすればよいですか。
以下は私のコードです:
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)