I'm just getting started with GeoPy and have been running some tests
to determine the quality of the different available geocoders. I have
noticed that Bing's geocoder is more accurate than Google's (for my
purposes, at least), but instead of returning a zip code, Bing returns
<built-in function zip>
rather than the zipcode. Any thoughts as to
why/ways to correct this?
Here's my test code:
from geopy import geocoders
g = geocoders.Google()
b = geocoders.Bing('<DEV KEY HERE>')
services = [g, b]
def search_list(addylist):
for address in addylist:
for x in services:
for place, (lat, lng) in x.geocode(address,
exactly_one=False):
print "%s: %s: %.9f, %.9f \n" % (x, place, lat, lng)
addy1 = '513 N 36th Ave , Seattle'
addy2 = '121 S First Street , La Conner'
addy3 = '854 NE 58th St, Seattle'
addylist = [addy1, addy2, addy3]
search_list(addylist)
My output is:
<geopy.geocoders.google.Google object at 0x18e75d0>: 513 36th Ave,
Seattle, WA 98122, USA: 47.606811900, -122.287247300
<geopy.geocoders.google.Google object at 0x18e75d0>: 513 N 36th St,
Seattle, WA 98103, USA: 47.651385400, -122.351573800
<geopy.geocoders.bing.Bing object at 0x18e76d0>: 513 N 36TH St,
Seattle, WA <built-in function zip>, United States: 47.651340485,
-122.351692200
<geopy.geocoders.google.Google object at 0x18e75d0>: 121 1st St, La
Conner, WA 98257, USA: 48.391576600, -122.496045800
<geopy.geocoders.google.Google object at 0x18e75d0>: 121 N 1st St, La
Conner, WA 98257, USA: 48.394719800, -122.494525700
<geopy.geocoders.bing.Bing object at 0x18e76d0>: 121 S 1ST St, La
Conner, WA <built-in function zip>, United States: 48.391513824,
-122.495391846
<geopy.geocoders.google.Google object at 0x18e75d0>: 854 NE 58th St,
Seattle, WA 98105, USA: 47.670977000, -122.317815000
<geopy.geocoders.bing.Bing object at 0x18e76d0>: 854 NE 58TH St,
Seattle, WA <built-in function zip>, United States: 47.670978546,
-122.317817688
Bing seems to be more consistent, only returning a single correct result rather than two results. The only issue is that Bing doesn't seem to want to return a zipcode, for some reason, rather it returns a string containing the address and <built-in function zip>
.
geocoders.Bing('DEV KEY').geocode('854 NE 58th St, Seattle')
returns the addess complete with a zipcode? PS, not