h3 is a set of Python bindings for Uber's H3 C library, a hierarchical hexagonal geospatial indexing system. It allows for efficient spatial indexing, querying, and analysis using hexagonal grids. The current version is 4.4.2, and it typically sees multiple releases per year, often in sync with updates to the underlying H3 C library.
pip install h3Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to convert geographic coordinates to an H3 index, retrieve its center and boundary, find its neighbors, and validate an H3 index.
Ensure your project is running on Python 3.10 or newer before upgrading to h3-py v4.5.0 or later.
Before passing cell sets to `cells_to_h3shape` or `cells_to_geo`, ensure all cells are unique and of the same resolution to avoid runtime errors.
For critical applications involving global polygons, upgrade to v4.5.0 or newer and ensure your input cell sets are valid according to the new strict validation rules (unique and same resolution).
Update your code to use the new function names, e.g., replace `h3.geo_to_h3(...)` with `h3.h3_geo_to_h3(...)`.
Ensure the package is installed using pip: `pip install h3` or `pip3 install h3`. If using a virtual environment or conda, activate it first.
Upgrade to the latest h3-py version (`pip install --upgrade h3`) and update your code to use the v4 API (e.g., `h3.latlng_to_cell` instead of `h3.geo_to_h3`, `h3.cell_to_boundary` instead of `h3.h3_to_geo_boundary`). Alternatively, if you need v3 behavior, explicitly install a v3 version (`pip install 'h3<4'`) and use its API.
This usually indicates a dependency conflict. Either downgrade `h3` to a compatible v3.x version for the dependent library (`pip install 'h3~=3.0'`) or upgrade the dependent library (e.g., `h3pandas`) to a version compatible with `h3-py` v4.x.
Ensure you are using a supported Python version (h3-py >=3.8). Update `pip` (`pip install --upgrade pip`). If on Windows, ensure you have a C++ compiler (like Visual Studio Build Tools) and CMake installed, as `h3` requires compiling its C core if a pre-built wheel isn't available.
When working with DataFrames (especially PySpark), use User-Defined Functions (UDFs) to apply `h3` functions row-wise on specific columns. For pandas, apply the function to a Series. Example for pandas: `df['h3_index'].apply(lambda x: h3.h3_to_parent(x, resolution))`.
No dependency data recorded yet.