Find file
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (38 sloc) 1.96 KB



sGeo is a very simple minimalistic geocoder built around Geonames, and Sphinx. You can try to geocode any place in the world or just restrict it to US cities and zip codes. sGeo will not geocode full addresses as they are not available in Geonames. It will only geocode cities, zip codes or places such as national parks, universities, etc ... sGeo was first written in late 2007 to batch geocode the contractor database used in Chiefmall.

Feel free to try a demo.


Read for installation instructions.

How to use within your code

import sgeo
gc = sgeo.GeoCoder(usa_only=True)

# querying Geonames
location = 'Newport Beach, CA'
coords = gc.get_locations(location, limit=5)

# using MaxMind GeoIP
location = ''
coords = gc.get_locations(location)

# using
location = '94720'
coords = gc.get_locations(location)

# using Geonames to find nearby hotels
hits = gc.get_nearby_places(, coords.lon, 'hotels', radius=50*1000, limit=10)
print hits

Use command line interface for testing

python sgeo/sgeo/ --usa-only 'Newport Beach, CA'


python [options] place_name'

    Use to test and debug sGeo at the command line.'

        -l, --limit  int            : (default is 1)'
        --usa                       : USA geocoding only'
        --nearby  int               : show top nearby places on geonames'
        --listen  host:port         : address to searchd (default localhost:9312)'
        -h, --help                  : this help message'