Created
August 5, 2014 23:50
-
-
Save wholmgren/6330bec8fc0813e65fcc to your computer and use it in GitHub Desktop.
get time zone from lat lon via google using python
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
import pytz | |
import requests | |
import numpy as np | |
now_timestamp = np.datetime64(datetime.datetime.utcnow()).astype(float)/1e6 | |
lat = 32.2 | |
lon = -111.9 | |
payload = {'location':'{},{}'.format(lat, lon), 'timestamp':str(now_timestamp)} | |
tz_response = requests.get('https://maps.googleapis.com/maps/api/timezone/json', params=payload) | |
thetz = pytz.timezone(tz_response.json()['timeZoneName']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment