I am using Google's Geocoding API using Python Libraries (tried GeoPy 1.11.0). For a query such as "Utica" I'm getting a single response:
{u'geometry': {u'location_type': u'APPROXIMATE', u'bounds': {u'northeast':
{u'lat': 43.132269, u'lng': -75.1609059}, u'southwest': {u'lat':
43.0644689, u'lng': -75.295296}}, u'viewport': {u'northeast': {u'lat':
43.132269, u'lng': -75.1609059}, u'southwest': {u'lat': 43.0644689, u'lng':
-75.295296}}, u'location': {u'lat': 43.100903, u'lng': -75.232664}},
u'address_components': [{u'long_name': u'Utica', u'types': [u'locality',
u'political'], u'short_name': u'Utica'}, {u'long_name': u'Oneida County',
u'types': [u'administrative_area_level_2', u'political'], u'short_name':
u'Oneida County'}, {u'long_name': u'New York', u'types':
[u'administrative_area_level_1', u'political'], u'short_name': u'NY'},
{u'long_name': u'United States', u'types': [u'country', u'political'],
u'short_name': u'US'}], u'place_id': u'ChIJKXZqNVE32YkRhvztGCY2GhE',
u'formatted_address': u'Utica, NY, USA', u'types': [u'locality',
u'political']}
The problem is that there are multiple Utica's in the US, for example Utica, NY and Utica, WI. I was expecting Google to return all possible places that have Utica in their name, is there a way to do this?
Here is the code utilizing GeoPy with Google:
locations = ["Utica"]
from geopy.geocoders import GoogleV3
geolocator = GoogleV3(api_key=GoogleAPIKey)
for location in locations:
print location
results = geolocator.geocode(query=location, language='en', exactly_one=False, timeout=5)
for result in results:
print result.raw