Skip to content

Instantly share code, notes, and snippets.

View emilepetrone's full-sized avatar
🏠
Working from home

Emile Petrone emilepetrone

🏠
Working from home
View GitHub Profile
import xlrd
import time
from simplegeo import Client, json, APIError
#from multiprocessing.pool import ThreadPool as Pool
from multiprocessing import Pool
def f(z):
z = str(z)
neighborhoods = []
error = ""
import xlrd
from simplegeo import Client, json, APIError
#from multiprocessing.pool import ThreadPool as Pool
from multiprocessing import Pool
def f(z):
z = str(z)
neighborhoods = []
error = ""
try:
import xlrd
from simplegeo import Client, json, APIError
from multiprocessing import Pool
def f(z):
z = str(z)
try:
// delete a place
[client deletePlace:@"SG_placeID"
callback:[SGCallback callbackWithSuccessBlock:
^(id response) {
// deletion confirmed
} failureBlock:^(NSError *error) {
// deletion failed
}]];
// update a place
[client updatePlace:@"SG_placeID"
withPlace:newPlace
callback:[SGCallback callbackWithSuccessBlock:
^(id response) {
// update confirmed
} failureBlock:^(NSError *error) {
// update failed
}]];
// add a place
SGPlace *place = [SGPlace placeWithName:@"SimpleGeo Headquarters"
point:[SGPoint pointWithLat:37.772445 lon:-122.405913]];
[place setClassifiers:***arrayOfClassifierDictionaries***] // optional
[place setProperties:***propertiesDictionary***] // optional
[place setTags:***arrayOfTags***]; // optional
[client addPlace:place
// find the three nearest Italian restaurants within five kilometers of an address
SGPlacesQuery *query = [SGPlacesQuery queryWithAddress:@"41 Decatur St, San Francisco, CA"];
[query setCategories:[NSArray arrayWithObjects:SGPlacesCategoryRestaurant, SGPlacesCategoryFood, nil]];
[query setSearchString:@"Italian"];
[query setRadius:5.0];
[query setLimit:3];
[client getPlacesForQuery:query
// find places near a point
SGPlacesQuery *query = [SGPlacesQuery queryWithPoint:[SGPoint pointWithLat:37.772445 lon:-122.405913]];
[client getPlacesForQuery:query
callback:[SGCallback callbackWithSuccessBlock:
^(id response) {
// you've got Places!
// to create an array of SGPlace objects...
NSArray *places = [NSArray arrayWithSGCollection:response
// get voting districts for an area
SGEnvelope *envelope = [SGEnvelope envelopeWithNorth:40.613952
west:-105.90271
south:39.078908
east:-103.513184];
[query setFilters:[NSArray arrayWithObject:SGContextFilterFeatures]];
[query setFeatureCategories:[NSArray arrayWithObjects:SGFeatureCategoryLegislativeDistrict,
SGFeatureCategorySchoolDistrict,
// get advanced demographic information for an address
SGContextQuery *query = [SGContextQuery queryWithAddress:@"41 Decatur Street, San Francisco, CA"];
[query setFilters:[NSArray arrayWithObject:SGContextFilterDemographics]];
[query setACSTableIDs:[NSArray arrayWithObjects:@"B05005", @"B06009", @"B07001", nil]];
[client getContextForQuery:query
callback:[SGCallback callbackWithSuccessBlock:
^(id response) {
// you've got demographics!