geopandas 和 geopy 的地理编码错误

Geocoding error with geopandas and geopy

根据 geopandas docs 我正在尝试对字符串列表进行地理编码,但出现错误。

我的环境

import geopandas as gdp
from geopandas.geocode import geocode
import geopy
import sys

print(sys.version)
print (gdp.__version__)
print (geopy.__version__)

3.4.3 |Anaconda 2.2.0 (x86_64)| (default, Mar  6 2015, 12:07:41) 
[GCC 4.2.1 (Apple Inc. build 5577)]
0.1.1
1.10.0

我正在努力

geocode(['boston, ma', '1600 pennsylvania ave. washington, dc'])

我收到以下错误

AttributeError                            Traceback (most recent call last)
<ipython-input-77-d7e5e2fb2b1d> in <module>()
----> 1 geocode(['boston, ma', '1600 pennsylvania ave. washington, dc'])

/Users/tbmh1/anaconda/envs/devData34/lib/python3.4/site-packages/geopandas-0.1.1-py3.4.egg/geopandas/geocode.py in geocode(strings, provider, **kwargs)
     70               'bing': geopy.geocoders.Bing,
     71               'yahoo': Yahoo,
---> 72               'mapquest': geopy.geocoders.MapQuest,
     73               'openmapquest': geopy.geocoders.OpenMapQuest,
     74               'nominatim' : geopy.geocoders.Nominatim}

AttributeError: 'module' object has no attribute 'MapQuest'

当文档说 googlev3 是默认提供程序时,我不知道为什么它要尝试执行 MapQuest。 python 2.7

我得到同样的错误

使用MapQuest无所谓;除非名称存在,否则 geopandas 无法构建该字典。 geopy 在 this commit:

中删除了那个编码器

MapQuest geocoder removed as the API it uses is now only available to enterprise accounts. OpenMapQuest is a replacement for Nominatim-sourced data.

同时,您可以通过将名称绑定到其他内容来解决这个问题,因此字典至少可以工作:

>>> geopy.geocoders.MapQuest = None
>>> geocode(['boston, ma', '1600 pennsylvania ave. washington, dc'])
                                             address  \
0                                    Boston, MA, USA   
1  1600 Pennsylvania Avenue Southeast, Washington...   

                         geometry  
0  POINT (-71.0588801 42.3600825)  
1  POINT (-76.9816788 38.8786589)