Created
January 28, 2019 18:35
-
-
Save KanishkVashisht/afc166bec4e7837168e211c0eec1c898 to your computer and use it in GitHub Desktop.
geocoder using gmaps client
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
#geocoding function using googlemaps python client | |
def geocode(address): | |
try: geocode_result = gmaps.geocode(address) | |
except: | |
print("Exception occured for "+address) | |
return (None, None, None) | |
geocode_result = geocode_result[0] | |
return (geocode_result['geometry']['location']['lat'], | |
geocode_result['geometry']['location']['lng'], | |
geocode_result['place_id'] | |
) | |
trip_data["start_lat"],trip_data["start_long"], trip_data["start_gplace_id"] = zip(*trip_data["StartLocation"].map(geocode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment