Offline timezone lookup for WGS84 coordinates, with no polygon simplification - so the answer stays correct at timezone borders.
In comparison to other alternatives this package aims at maximum accuracy around timezone borders while offering fast lookup performance and compatibility with many (Python) runtime environments. It combines preprocessed polygon data, H3-based spatial shortcuts, and optional acceleration via Numba or a clang-backed point-in-polygon routine.
Quick Guide
It is recommended to install it together with the optional Numba package for increased performance:
pip install timezonefinder[numba]
The timezone boundary data is installed automatically as the separate timezonefinder-data distribution, so that a new dataset ships without a new timezonefinder release. Pin it to hold a deployment to one dataset - the release history lists the versions to choose from: pip install timezonefinder "timezonefinder-data==<version>".
# use the global function for convenience:
from timezonefinder import timezone_at
tz = timezone_at(lng=13.358, lat=52.5061) # 'Europe/Berlin'
# For improved performance and control, create and reuse an instance:
from timezonefinder import TimezoneFinder
tf = TimezoneFinder(in_memory=True) # reuse
query_points = [(13.358, 52.5061), ...]
for lng, lat in query_points:
tz = tf.timezone_at(lng=lng, lat=lat) # 'Europe/Berlin'
Note: This library uses the full original timezone dataset with all >440 timezone names, providing full localization capabilities and historical timezone accuracy. For applications that prefer a smaller memory footprint, the reduced “timezones-now” dataset is available via the update_data.sh script (cf. Documentation).
How it works
A lookup scales the coordinates to 32-bit integers (x 10^7, ~1 cm resolution), finds the point’s H3 hexagon at resolution 3, and reads a precomputed shortcut for that cell. Most cells are covered by a single timezone, so the answer is returned immediately with no geometry touched at all. Only an ambiguous cell falls through to the polygons it lists: bounding-box rejection first, then a ray-casting point-in-polygon test - holes before the outer ring, since holes are smaller and can reject the polygon outright.
The central trade-off: the boundary polygons are never simplified, so border accuracy is limited only by the source dataset. The H3 index is what makes carrying full-resolution geometry affordable.
Since the dataset includes ocean zones, every coordinate on earth matches some timezone - use timezone_at_land() when you need to tell land from sea.
Performance
Hundreds of thousands of lookups per second on a single core for uniformly random query points. The exact figure depends on the acceleration backend, the machine and the dataset version, so the benchmark reports below carry it - each states the configuration it was measured in - rather than this page, which would go stale.
The point-in-polygon routine has three interchangeable backends, selected at import time: a clang-compiled C extension (built automatically when a compiler is available), Numba JIT compilation (preferred when the optional dependency is installed), and pure Python. The pure-Python fallback is ~400x slower and always correct - a missing compiler costs speed, never results.
benchmark trend chart - appended to on every push to master
benchmark reports - lookup, point-in-polygon, initialization and memory
benchmarking methodology - how these numbers are produced and what they can and cannot tell you
Engineering notes
Architecture - the lookup pipeline, the acceleration backends, and the ceilings this package deliberately does not exceed
Data Format - binary layouts, coordinate scaling and the H3 index
Benchmarking Methodology - the measurement design and where every threshold comes from
Testing philosophy - the tests that exist because a rule needed a failure mode, plus the property-based suite and the version/backend matrix
How it ships - abi3 wheels, three libc targets, and the checks that stop a broken wheel reaching PyPI
Alternatives - the trade-offs against tzfpy, and when to choose it instead
Alternative: Need maximum speed at the cost of accuracy? Check out tzfpy - a fast and lightweight alternative based on Rust.
Contributing
Looking for maintainers. Reach out if you want to contribute!
Contribution guidelines, the development workflow and the testing/benchmarking gates are documented in CONTRIBUTING.md.
References
LICENSE
timezonefinder is licensed under the MIT license.
The data ships in the separate timezonefinder-data distribution and is licensed under the ODbL license, following the base dataset from evansiroky/timezone-boundary-builder.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timezonefinder-8.3.0.tar.gz.
File metadata
- Download URL: timezonefinder-8.3.0.tar.gz
- Upload date:
- Size: 764.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
827c056552d7ba481336e62fff58f3a7c81687233d5dc000b13fefaa25c89525
|
|
| MD5 |
0508e59e30a47218a2c9ed495e363c67
|
|
| BLAKE2b-256 |
073c78a7ce494c0d83cec7c1619a7ac76a751df06adbcc11dc7f90733ef3ecb2
|
File details
Details for the file timezonefinder-8.3.0-cp311-abi3-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: timezonefinder-8.3.0-cp311-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 85.9 kB
- Tags: CPython 3.11+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f14364389fceec16915826bc6701bccc074b0159269d0447c8bcf0d647d509b
|
|
| MD5 |
690b0c1bdf951afdbf9f15fc395a254b
|
|
| BLAKE2b-256 |
73e90c582a773c6d1335544559e52ea5534211706b488bd601bf2a9ff5b78c5c
|
File details
Details for the file timezonefinder-8.3.0-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: timezonefinder-8.3.0-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 83.8 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c41ddb7d0518c4df668b705e01c0523e1ca496d75c5721b30a1b03ddd9ae75
|
|
| MD5 |
cc1225593b531791e250625f08b054f6
|
|
| BLAKE2b-256 |
d335171e01f0940e979c3a4c6a0562996a4ba9a424adca671663ce0c9a244231
|
File details
Details for the file timezonefinder-8.3.0-cp311-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: timezonefinder-8.3.0-cp311-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 83.9 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2413777e443f45260128cdb58db449b16c7783ce414de499475d81500dd5bdf
|
|
| MD5 |
9392eae6a83da18eafe08ce0a766c03e
|
|
| BLAKE2b-256 |
0e1f65048c4d530e0781d43433b8863551352df4b04d4667089624a584ad6de6
|