Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A fork of the geocoding library geopy. Returns accuracy scores. Allows viewport biasing.
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
geopy
.gitignore
LICENSE
README.textile
requirements.txt
setup.py

README.textile

This library is no longer supported and probably should not be used. If you would like to access Google’s v3 geocoder with Python, try python-googlegeocoder.

                                              ,,                                          
`7MMM.     ,MMF'                              db                           `7MMF'            db      
  MMMb    dPMM                                                               MM             ;MM:     
  M YM   ,M MM   ,6"Yb. `7MMpdMAo.`7MMpdMAo.`7MM  `7MMpMMMb.  .P"Ybmmm       MM            ,V^MM.    
  M  Mb  M' MM  8)   MM   MM   `Wb  MM   `Wb  MM    MM    MM :MI  I8         MM           ,M  `MM    
  M  YM.P'  MM   ,pm9MM   MM    M8  MM    M8  MM    MM    MM  WmmmP"         MM      ,    AbmmmqMA   
  M  `YM'   MM  8M   MM   MM   ,AP  MM   ,AP  MM    MM    MM 8M              MM     ,M   A'     VML  
.JML. `'  .JMML.`Moo9^Yo. MMbmmd'   MMbmmd' .JMML..JMML  JMML.YMMMMMb      .JMMmmmmMMM .AMA.   .AMMA.
                          MM        MM                       6'     dP                               
                        .JMML.    .JMML.                     Ybmmmd'                                 

A fork of the geocoding library geopy, modified, with a few new toys.

Includes:

  • An option to return an accuracy score along with the result

How it works

First fire up geopy and load the Google geocoder like you normally would.

$ python
>>> from geopy import geocoders
>>> g = geocoders.Google(BENS_GOOGLE_API_KEY)

Now run an address like you typically would and see the usual output. Let’s try the address of the Los Angeles Times.

>>> point_generator = g.geocode('202 W. 1st St., Los Angeles, Los Angeles, CA', exactly_one=False)
>>> from pprint import pprint
>>> pprint(list(point_generator))
[(u'202 W 1st St, Los Angeles, CA 90731, USA',
  (33.743286099999999, -118.28143780000001)),
 (u'202 W 1st St, Los Angeles, CA 90012, USA',
  (34.052993000000001, -118.24482500000001))]

Unfortunately, we get two results in LA for the same address. Let’s use my new optional keyword argument, ‘return_accuracy’ so see how good they are.

>>> point_generator = g.geocode('202 W. 1st St., Los Angeles, Los Angeles, CA', exactly_one=False, return_accuracy=True)

You’ll see that the generator now includes the accuracy score at the tail end. You can decode the number here. Eight is pretty good.

>>> pprint(list(point_generator))
[(u'202 W 1st St, Los Angeles, CA 90731, USA',
  (33.743286099999999, -118.28143780000001),
  u'8'),
 (u'202 W 1st St, Los Angeles, CA 90012, USA',
  (34.052993000000001, -118.24482500000001),
  u'8')]

But they’re both at the same high accuracy level. Why? Because that address occurs both in Downtown L.A. and in the long-ago annexed neighborhood of San Pedro.

Something went wrong with that request. Please try again.