Skip to content
python library to look up timezone from lat lng offline
Branch: master
Clone or download
Keith and pegler Update README to include example for forceTZ
Almost used another library until I discovered this parameter. I think it would be helpful to have in README
Latest commit 32d2bef Feb 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Reduces size of module bt 1/3. Achieves 94% code coverage, relating to Aug 22, 2017
tzwhere Reduces size of module bt 1/3. Achieves 94% code coverage, relating to Aug 22, 2017
.coveragerc Use the right sort key inside `forceTz` (#40) May 25, 2017
.gitignore
.travis.yml test python 2.7 May 25, 2017
LICENSE Package tzwhere for PyPi Dec 18, 2013
MANIFEST.in add worldtest.json.gz to manifest. bump version Aug 24, 2017
README.md Update README to include example for forceTZ Feb 14, 2018
geojson-conversion.sh
getOriginalData.sh Fix type in 'shp' extension Nov 27, 2015
index.html Fixed polygon "hole" bug May 12, 2016
setup.py add worldtest.json.gz to manifest. bump version Aug 24, 2017

README.md

pytzwhere Build Status Coverage Status

pytzwhere is a Python library to lookup the timezone for a given lat/lng entirely offline.

Version 3.0 fixes how pytzwhere deals with holes in timezones. It is recommended that you use version 3.0.

It is a port from https://github.com/mattbornski/tzwhere with a few improvements. The underlying timezone data is based on work done by Eric Muller

If used as a library, basic usage is as follows:

>>> from tzwhere import tzwhere
>>> tz = tzwhere.tzwhere()
>>> print tz.tzNameAt(35.29, -89.66)
America/Chicago

The polygons used for building the timezones are based on VMAP0. Sometimes points are outside a VMAP0 polygon, but are clearly within a certain timezone (see also this discussion). As a solution you can search for the closest timezone within a user defined radius.

Dependencies:

  • numpy (optional)

  • shapely

forceTZ

If the coordinates provided are outside of the currently defined timezone boundaries, the tzwhere function will return None. If you would like to match to the closest timezone, use the forceTZ parameter.

Example:

>>> from tzwhere import tzwhere
>>> tz = tzwhere.tzwhere()
>>> print(tz.tzNameAt(53.68193999999999, -6.239169999999998))
None

>>> from tzwhere import tzwhere
>>> tz = tzwhere.tzwhere(forceTZ=True)
>>> print(tz.tzNameAt(53.68193999999999, -6.239169999999998, forceTZ=True))
Europe/Dublin
You can’t perform that action at this time.