-
-
Save schuyler/1040656 to your computer and use it in GitHub Desktop.
Find centroid for Polygon
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
from shapely.geometry import asShape | |
from simplegeo import context | |
client = context.Client('your-key','your-secret') | |
context_response = client.get_context(37.775255,-122.40289) | |
neighborhoods = [feature for feature in context_response['features'] if feature['classifiers'][0]['category'] == 'Neighborhood'] | |
if neighborhoods: | |
neighborhood_handle = neighborhoods[0]['handle'] | |
neighborhood_boundary = asShape(client.get_feature(neighborhood_handle).to_dict()['geometry']) | |
centroid = neighborhood_boundary.centroid.wkt | |
print centroid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment