简体   繁体   中英

Geocoding error with geopandas and geopy

Per the geopandas docs I'm trying to geocode a list of strings, but I'm getting an error.

My env

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

I'm trying to do

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

and I'm getting the following error

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'

I have no clue why it's trying to do MapQuest when the docs say googlev3 is the default provider. I get the same error with python 2.7

It doesn't matter whether or not it uses MapQuest ; geopandas can't build that dictionary unless the name exists. geopy removed that coder in 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.

In the meantime, you could work around it by binding the name to something else, so the dictionary works at least:

>>> 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM