Created
July 5, 2011 22:54
-
-
Save anonymous/1066147 to your computer and use it in GitHub Desktop.
Find all neighborhoods in a given city, by address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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