Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
I can't seem to reproduce this behavior--I see ZIP Codes for each example entry. Can you post more information about your OS, python version, geopy version, etc...? –  mdwhatcott Mar 13 '12 at 4:10
    
BTW, this question seems more suited for stackoverflow.com. –  mdwhatcott Mar 13 '12 at 18:39
    
I'm using Linux Mint 10, Python 2.7, GeoPy 0.94.1. What are you using? Strange that it's working for you, so geocoders.Bing('DEV KEY').geocode('854 NE 58th St, Seattle') returns the addess complete with a zipcode? PS, not –  alukach Mar 14 '12 at 0:51
    
I'm running OS X Lion, Python 2.7.2, GeoPy 0.94.2 (that's what PIP pulled down). Yes, I am seeing the actual ZIP Codes for bing results, not <built-in function zip>. –  mdwhatcott Mar 15 '12 at 5:44
    
Okay, that looks like it was the issue. I had a friend run the code and he got the same results as you. It looks like the problem, whatever it was, was resolved in GeoPy 0.94.2. Uninstalled 0.94.1, installed 0.94.2, and it's all good now. –  alukach Mar 21 '12 at 22:43

1 Answer 1

Not sure if this would help, but you could use an address verification provider that includes geocoding. I'm a developer at SmartyStreets, just such a provider. Check out this example JSON response (scroll down).

Google and Bing are great address approximation services but you can run into trouble with their license agreements depending on what you're trying to accomplish. We offer a free forever plan for low-usage customers, and it's absolutely free to non-profits.

share|improve this answer
    
Hey, this looks great, I think I'm going to try giving this a go. You're right, this is better in terms of licensing agreements for my project. Thanks. –  alukach Mar 21 '12 at 22:41
    
Out of curiosity, where is your data coming from? –  alukach Mar 21 '12 at 23:09
    
Our data comes from the USPS, with which SmartyStreets is a CASS-Certified Licensee. en.wikipedia.org/wiki/Coding_Accuracy_Support_System –  mdwhatcott Mar 22 '12 at 19:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.