{"id":1503,"library":"h3","title":"H3 Python Bindings","description":"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.","status":"active","version":"4.4.2","language":"en","source_language":"en","source_url":"https://github.com/uber/h3-py","tags":["geospatial","h3","mapping","hexagonal","spatial-indexing"],"install":[{"cmd":"pip install h3","lang":"bash","label":"Install h3"}],"dependencies":[],"imports":[{"symbol":"h3","correct":"import h3"}],"quickstart":{"code":"import h3\n\n# Example coordinates: San Francisco\nlat, lon = 37.7749, -122.4194\n\n# 1. Get an H3 index for a given lat/lon at a specific resolution\nresolution = 9\nh3_index = h3.geo_to_h3(lat, lon, resolution)\nprint(f\"H3 Index for ({lat}, {lon}) at resolution {resolution}: {h3_index}\")\n\n# 2. Get the geographic coordinates of the center of an H3 index\ncenter_coords = h3.h3_to_geo(h3_index)\nprint(f\"Center coordinates of {h3_index}: {center_coords}\")\n\n# 3. Get the boundary (polygon) of an H3 index\nboundary = h3.h3_to_geo_boundary(h3_index)\nprint(f\"Boundary of {h3_index} (first 2 points): {boundary[:2]}...\")\n\n# 4. Find immediate neighbors of an H3 index (k-ring with distance 1)\nneighbors = h3.h3_k_ring(h3_index, 1)\nprint(f\"Neighbors of {h3_index}: {list(neighbors)}\")\n\n# 5. Check if an H3 index is valid\nis_valid = h3.h3_is_valid(h3_index)\nprint(f\"Is {h3_index} valid? {is_valid}\")","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your project is running on Python 3.10 or newer before upgrading to h3-py v4.5.0 or later.","message":"Future versions of h3-py (e.g., v4.5.0 stable) will drop support for Python 3.8 and 3.9. The minimum supported Python version will be 3.10.","severity":"breaking","affected_versions":">=4.5.0a1"},{"fix":"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.","message":"The functions `cells_to_h3shape` and `cells_to_geo` will become stricter in their input validation. Supplying duplicate cells will now raise an `H3DuplicateInputError`, and supplying cells of mixed resolutions will raise an `H3ResMismatchError`.","severity":"breaking","affected_versions":">=4.5.0a2"},{"fix":"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).","message":"Prior to v4.5.0a2, `cells_to_h3shape` and `cells_to_geo` could produce incorrect results or fail silently for polygons that cross the antimeridian or poles, or for very large polygons. While newer versions fix this behavior, they also introduce stricter input validation (see breaking change above).","severity":"gotcha","affected_versions":"<4.5.0a2"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}