場所の名前と、住所番号、通りの名前、都市、郵便番号、国を含む解析済み住所を含む CSV ファイルをジオコーディングしようとしています。Geopy を介して GEOPY と ArcGIS Geocodes を使用したいと考えています。5000 以上のエントリの csv をループして、CSV の別々の列に緯度と経度を表示するコードを作成したいと考えていました。Geopy を介して ArcGIS Geocoding サービスを使用したいと考えています。開始するためのコードを教えてもらえますか? ありがとう!
これが私のスクリプトです:
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)