Skip to content

Instantly share code, notes, and snippets.

Created July 5, 2011 22:54
Show Gist options
  • Save anonymous/1066147 to your computer and use it in GitHub Desktop.
Save anonymous/1066147 to your computer and use it in GitHub Desktop.
Find all neighborhoods in a given city, by address
>>> import simplegeo
>>> from itertools import ifilter
>>> client = simplegeo.context.Client('your-key','your-secret')
>>> location = client.get_context_by_address("41 Decatur St, San Francisco, CA")
# Find the bounding box of your current city
>>> sf = next(ifilter(lambda feature: feature['classifiers'][0]['category'] == 'Administrative', location['features']), None)
>>> hoods = client.get_features_from_bbox(sf['bounds'], features__category='Neighborhood')
>>> for hood in hoods['features']:
... print hood['properties']['name']
Golden Gate Heights
Balboa Terrace
Pacific Highlands
Merced Heights
Ingleside Terrace
Ingleside Heights
Mount Davidson Manor
Lake District
Forest Hill
Monterey Heights
Inner Richmond
Inner Sunset
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment