H3_CELL_TO_STRING

Format an H3 cell index as its canonical 15 hexadecimal-digit string representation.

Category: h3Returns: STRINGDialect: Standard

Syntax

H3_CELL_TO_STRING(cell)

Description

## Overview Returns the canonical 15 hexadecimal-digit string representation of an H3 cell index. H3 cells can be exchanged either as 64-bit integers or as lowercase hex strings such as `892830926dfffff`. The string form is commonly preferred in APIs, URLs, log output, and any context where BIGINT can be ambiguous (for example languages that lack a native uint64 type). This function is the inverse of H3_STRING_TO_CELL. The pair is safe for round-tripping: for any valid cell, H3_STRING_TO_CELL(H3_CELL_TO_STRING(c)) returns the same cell. ## Behavior - Returns a STRING containing up to 15 lowercase hex digits. No `0x` prefix, no leading zeros. - Pure formatting: the function does not validate that the value is a real H3 cell, it simply formats the bits. - For the zero input it returns '0'. - Deterministic: the same input always returns the same string. - The output string is stable across engines that implement the standard H3 library. ## H3 resolution reference | Res | Average edge length | Average hex area | | --- | --- | --- | | 0 | 1,107 km | 4.25 million km^2 | | 7 | 1.22 km | 5.16 km^2 | | 9 | 174 m | 0.11 km^2 | | 12 | 9.4 m | 307 m^2 | | 15 | 0.5 m | 0.9 m^2 | ## Compatibility - Follows the standard H3 hierarchical hex grid specification for string representation.

Parameters

NameTypeDescription
cellSpecifies the H3 cell index to format. Any BIGINT is accepted; the function does not validate that the value represents a real H3 cell.

Examples

-- Resolution 9 cell over San Francisco, expect '892830926dfffff'.
SELECT H3_CELL_TO_STRING(H3_LATLNG_TO_CELL(37.7749, -122.4194, 9)) AS cell_str;
SELECT
  H3_CELL_TO_STRING(c)                         AS as_string,
  H3_STRING_TO_CELL(H3_CELL_TO_STRING(c))       AS round_trip,
  c = H3_STRING_TO_CELL(H3_CELL_TO_STRING(c))   AS equal
FROM (SELECT H3_LATLNG_TO_CELL(51.5074, -0.1278, 9) AS c);
-- Convert integer cell IDs to strings for clients that expect the 15 hex-digit form.
SELECT event_id,
       H3_CELL_TO_STRING(h3_res9) AS h3_id
FROM analytics.curated.h3_events_res9;
SELECT
  H3_CELL_TO_STRING(H3_LATLNG_TO_CELL(35.6762, 139.6503, 7)) AS tokyo_res7,
  H3_CELL_TO_STRING(H3_LATLNG_TO_CELL(35.6762, 139.6503, 9)) AS tokyo_res9;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →