Reputation: 1265
Using geopy to geocode alcohol outlets in NZ.
The problem I have is that some places do not have street addresses but are places in Google Maps. For example, plugging:
Furneaux Lodge, Endeavour Inlet, Queen Charlotte Sound, Marlborough 7250
into Google Maps via the browser GUI gives me
However, using that in Geopy I get a GQueryError saying this geographic location does not exist.
Here is the code for geocoding:
def GeoCode(address):
g=geocoders.Google(domain="maps.google.co.nz")
geoloc = g.geocode(address, exactly_one=False)
place, (lat, lng) = geoloc[0]
GeoOut = []
GeoOut.extend([place, lat, lng])
return GeoOut
GeoCode("Furneaux Lodge, Endeavour Inlet, Queen Charlotte Sound, Marlboroguh 7250")
Meanwhile, I notice that "Eiffel Tower" works fine. Is there away to solve this and can someone explain the difference between The Eiffel Tower and Furneaux Lodge within Google 'locations'?
Upvotes: 2
Views: 1766
Reputation: 11213
Maybe this is a Google Maps API limitation. GeoNames however seems to know about Furneaux Lodge
, so you can use it as a fallback to Google Maps if the Google Maps query doesn't return an answer:
>>> from geopy import geocoders
>>> gn = geocoders.GeoNames()
>>> place, (lat, lng) = gn.geocode('Furneaux Lodge')
>>> print('{}: {:.5f}, {:.5f}'.format(place, lat, lng))
Furneaux Lodge, F4, NZ: -41.08826, 174.18019
Upvotes: 2