MeridianMERIDIAN

H3 Hex Index

geography.index.h3

Uber H3 hierarchical hexagonal spatial index. A 15-character lowercase hexadecimal string encoding resolution (0-15) and cell position.

Casts to
VARCHAR

Shape

Pattern
^[0-9a-f]{15}$
ValueLengthShape
8928308280fffff15matches
891f1d4c6c7ffff15matches
8a2a1072b59ffff15matches
872830828ffffff15matches
8e28308280f0e4f15matches
8928308280ffff14rejected: one character short

Background

Origin

H3 is a geospatial indexing system that partitions the world into hexagonal cells.[1] H3 was developed to address the challenges of Uber's data science needs.[1] Uber's post describes H3 as its grid system for efficiently optimising ride pricing and dispatch.[2] Uber's post explains the choice of hexagons by noting that hexagons have only one distance between a hexagon centrepoint and its neighbours'.[2] Uber's post also says that hexagons minimise the quantisation error introduced when users move through a city.[2] H3 is open source under the Apache 2 licence.[1] The H3 library is written in C, and bindings are available for a number of languages.[2]

H3 supports sixteen resolutions.[2] Each finer H3 resolution has cells with one seventh the area of the coarser resolution.[2] Uber's post notes that the finer cells are only approximately contained within a parent cell.[2] An H3Index is the 64-bit integer representation of an H3 index.[3] The H3 documentation defines several index modes, of which mode 1 is an H3 Cell (hexagon or pentagon) index.[3] An H3 cell index packs its components into a 64-bit integer in order, highest bit first.[4] An H3 cell index uses 4 bits to indicate the cell resolution, from 0 to 15.[4] An H3 cell index uses 7 bits to indicate the base cell, from 0 to 121.[4] An H3 cell index uses 3 bits for each subsequent digit, from resolution 1 up to the resolution of the cell, each digit holding a value from 0 to 6.[4] In an H3 cell index, the three bits for each unused digit are set to 7.[4] The canonical string representation of an H3Index is the hexadecimal representation of the integer, using lowercase letters.[3]

Use

DuckDB's h3 community extension is installed with INSTALL h3 FROM community and loaded with LOAD h3.[5] DuckDB's h3 extension provides h3_string_to_h3, which converts a VARCHAR cell ID to UBIGINT.[5] DuckDB's h3 extension provides h3_is_valid_cell, which is true if its argument is a valid cell ID.[5] Snowflake's H3_LATLNG_TO_CELL_STRING function returns a VARCHAR value holding the hexadecimal H3 cell ID for a given location and resolution.[6] Databricks provides h3_stringtoh3, which converts a hexadecimal string representing an H3 cell ID to its BIGINT form.[7] Databricks recommends the big integer representation of H3 cell IDs for the best performance.[7]

Read the resolution of the cells before you aggregate or join, since a column that mixes resolutions is easy to miss by eye. (Meridian's view)

Where you'll meet it

Kontur's global population dataset on the Humanitarian Data Exchange publishes vector H3 hexagons with population counts at 400m resolution.[8] The Kontur Population codebook lists an h3 field holding the H3 index of each hexagon.[8]

Detection notes

Uber H3 geospatial indexing system. Resolution 0 (coarsest) to 15 (finest). DuckDB h3 extension provides conversion functions.

Use it

CLI · DuckDB
$ finetype infer -i "8928308280fffff" --mode column
→ geography.index.h3

SELECT ft_infer('8928308280fffff');
-- → 'geography.index.h3'
Cast expression
CAST({col} AS VARCHAR)

Schema

https://meridian.online/schemas/geography.index.h3 · Frictionless type string

finetype taxonomy geography.index.h3 -o json-schema

Aliases

h3_indexh3_cell

Type Registry