Created
October 2, 2013 20:36
-
-
Save joannecheng/6800144 to your computer and use it in GitHub Desktop.
Google Places exporter. Pass in lat/lng increment, bounding coordinates, search_query. Queries the google places API and exports csv with closest distance to the place that matches your search query.
This file contains hidden or 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
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY') | |
class GooglePlacesExporter: | |
column_headers = ['lat', 'lng', 'latnear', 'lngnear', 'dist_miles'] | |
def __init__(self, lat_incr=-0.29, lng_incr=0.29, search_query='grocery_or_supermarket', lat_NW=49.44098806129775,lng_NW=-127.13476612499217, lat_SE=23.725012, lng_SE=-61.347656): | |
self.lat_incr = lat_incr | |
self.lng_incr = lng_incr | |
self.lat_curr = lat_NW | |
self.lng_curr = lng_NW | |
# Bounding box | |
self.lat_NW = lat_NW | |
self.lng_NW = lng_NW | |
self.lat_SE = lat_SE | |
self.lng_SE = lng_SE | |
self.rows = [] | |
self.google_url = "https://maps.googleapis.com/maps/api/place/search/json" | |
self.google_url_params_string = '?%(location)s&sensor=false&key='+GOOGLE_API_KEY+'&%(radius)s&types='+search_query |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment