My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 09, 2009 by david.ziegler
Labels: Phase-Deploy, Featured
ReverseGeocoding  
Reverse Geocoding with Geopy

Introduction

Reverse geocoding is the process of taking a lat,lng coordinate and translating it into a human readable address. Currently only the Google and GeoNames geocoders have reverse geocoding ability.

Installation

The reverse geocoding feature is currently in an experimental but stable development branch, which you can checkout here:

svn checkout http://geopy.googlecode.com/svn/branches/reverse-geocode geopy
cd geopy/
sudo python setup.py install

You may have to delete your old geopy installation.

Usage

All of the normal geopy features (geocoding, distance calculation, parsing, etc) found in trunk should work in this development branch.

Using the Google geocoder:

from geopy import geocoders

g = geocoders.Google(GOOGLE_KEY)
(place, point) = g.geocode("562 Kendall Ave, Palo Alto, CA")
print place
>> "562 Kendall Ave, Palo Alto, CA 94306, USA"
print point
>>(37.417447799999998, -122.1338166)

(new_place,new_point) = g.reverse(point)
print new_place
>> "543-567 Kendall Ave, Palo Alto, CA 94306, USA"
print new_point
>> (37.417447799999998, -122.1338166)

Using the GeoNames geocoder:

from geopy import geocoders

g = geocoders.GeoNames()
(place, point) = g.geocode("Palo Alto, CA 94306")
print place
>> "Palo Alto, US 94306"
print point
>> (37.418008999999998, -122.127375)

(new_place,new_point) = g.reverse(point)
print new_place
>> 3998 Ventura Ct, Palo Alto, US 94306 
print new_point
>> (37.417850000000001, -122.12793000000001)

Comment by k0Scist, May 29, 2009

I hope this is merged to trunk soon. If not, I hope that some sort of tag is added so that I can meaningfully put this in setup.py files. I am having a hard time trying to peg to this version of geopy for a project that needs it, as it finds the default geopy instead.


Sign in to add a comment
Hosted by Google Code