【问题标题】:Geocoding using Geopy ArcGIS and Python使用 Geopy ArcGIS 和 Python 进行地理编码
【发布时间】:2015-07-07 18:27:35
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

    标签: python csv geocode geopy


    【解决方案1】:

    名称,纬度经度尚未在该范围内的行中定义

    output_row['Name'] = Name
    output_row['Address'] = Address
    output_row['Latitude'] = Latitude
    output_row['Longitude'] =Longitude
    

    那里应该是纬度,经度。名字,我猜应该是 row['Name']。 您还可以发布您的 csv 文件的 sn-p(标题和 1-2 行)吗?

    【讨论】:

      猜你喜欢
      • 2015-09-24
      • 2015-10-07
      • 2020-02-16
      • 2021-01-26
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      相关资源
      最近更新 更多