Skip to main content

Python library to look up timezone from lat / long offline

Project description

pytzwhere [![Build Status](https://travis-ci.org/pegler/pytzwhere.svg)](https://travis-ci.org/pegler/pytzwhere) [![Coverage Status](https://coveralls.io/repos/pegler/pytzwhere/badge.svg)](https://coveralls.io/r/pegler/pytzwhere)
=========

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

It is a port from https://github.com/mattbornski/tzwhere with a few improvements.

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

>>> from tzwhere import tzwhere
>>> tz = tzwhere.tzwhere()
Reading json input file: tz_world_compact.json
>>> print tz.tzNameAt(35.29, -89.66)
America/Chicago

By default (and as shown above), the `tzwhere` class (at the heart of this library) initialises itself from a JSON file. Note that this is very very memory hungry (about 250MB, though the file is much smaller). You can save a lot of memory (hundred of megabytes), by telling `tzwhere` to read its data in (one line at a time) from a CSV file instead:

>>> tz = tzwhere.tzwhere(input_kind='csv')
Reading from CSV input file: tz_world.csv
>>> print tz.tzNameAt(35.29, -89.66)
America/Chicago

The module can also be run as a script, which offers some other possibilities including producing the CSV file mentioned above. Instructions and usage information can be seen by running:

tzwhere.py --help

Dependencies (both optional):

* `docopt` - if you want to use `tzwhere.py` as a script (e.g. as shown above).

* `numpy` - if you want to save about 200MB of RAM.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tzwhere-2.0.tar.gz (54.7 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page