timezonefinder

https://github.com/jannikmi/timezonefinder/actions/workflows/build.yml/badge.svg?branch=master documentation status https://img.shields.io/pypi/wheel/timezonefinder.svg pre-commit total PyPI downloads latest version on PyPI latest version on conda-forge supported python versions linted and formatted with ruff Coordinate to IANA timezone lookup

This is a python package providing offline timezone lookups for WGS84 coordinates. In comparison to other alternatives this package aims at maximum accuracy around timezone borders (no geometry simplifications) 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.

How it works

A lookup scales the coordinates to 32-bit integers (x 107, ~1 cm resolution), finds the point’s H3 hexagon at resolution 4 (~288k cells worldwide), 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. Architecture walks through the full pipeline; Data Format documents the binary layouts.

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, and Benchmarking Methodology describes how the resulting numbers are measured.

Since the dataset includes ocean zones, every coordinate on earth matches some timezone - timezone_at() therefore effectively never returns None; use timezone_at_land() when you need to tell land from sea.

References

Project

Indices and tables