python - Getting Time Zone from Lat Long Coordinates? -


i trying time zones latitude , longitude coordinates having few problems mistakes basic

i have table in database around 600 rows. each row contains lat long coordinate somewhere in world want feed these co-ordinates function , retrieve time zone. aim being convert events have local time stamp within each of these 600 places utc time

i found blog post uses a piece of code derive timezones geographical coordinates.

when try run code, error geonames not defined. have applied account geonames.

i think have saved function file in wrong directory or simple. can help

#------------------------------------------------------------------------------- # converts latitude longitude time zone # ref: https://gist.github.com/pamelafox/2288222 # ref: http://blog.pamelafox.org/2012/04/converting-addresses-to-timezones-in.html #-------------------------------------------------------------------------------  geonames_client = geonames.geonamesclient('username_alpha') geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng': 2.77928}) user.timezone = geonames_result['timezoneid'] 

this works expected:

import geonames geonames_client = geonames.geonamesclient('demo') geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng': 2.77928}) print geonames_result['timezoneid'] 

output:

'europe/paris' 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -