Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Simple script to determine name, lat/long and timezone of a place name.
import urllib2
import pytz
import json
from geocoders.geonames import geocode
def get_timezone(lat, lng):
url = "" % (lat, lng)
data = urllib2.urlopen(url)
return pytz.timezone(json.load(data)[u'timezoneId'])
def locate(place):
name, coords = geocode(place)
tz = get_timezone(*coords)
return (name, coords, tz)
print locate("Edmonton, alberta")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.