Geolocation and timezones in Python
I’m a hobby astronomer and part of my tool chain is Python. When I quickly need
to get the geographical coordinates and timezone for any given named location
on earth I simply use the geopy
and tzwhere
packages.
>>> from geopy.geocoders import Nominatim
>>> GeoLocator = Nominatim(user_agent='test')
>>> GeoLocator.geocode('Düsseldorf')
Location(Düsseldorf, Nordrhein-Westfalen, 40213, Deutschland, (51.2254018, 6.7763137, 0.0))
>>> from tzwhere import tzwhere
>>> tzwhere = tzwhere.tzwhere()
>>> tzwhere.tzNameAt(51.2254018, 6.7763137)
'Europe/Berlin'