Skip to content

Instantly share code, notes, and snippets.

@KanishkVashisht
Created January 28, 2019 18:35
Show Gist options
  • Save KanishkVashisht/afc166bec4e7837168e211c0eec1c898 to your computer and use it in GitHub Desktop.
Save KanishkVashisht/afc166bec4e7837168e211c0eec1c898 to your computer and use it in GitHub Desktop.
geocoder using gmaps client
#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