Return the WGS 84 longitude of the center of an H3 cell.
H3_CELL_TO_LNG(cell)
## Overview Returns the WGS 84 longitude in decimal degrees of the geometric center of an H3 cell. Every H3 cell has a well-defined centroid; this function extracts the longitude component. Pair it with H3_CELL_TO_LAT for the full center point, or use H3_CELL_TO_BOUNDARY to get the cell as a polygon. Use this when serializing H3 aggregates back to point data for mapping tools, for distance calculations, or to filter cells by geographic band. ## Behavior - Returns a DOUBLE in the range [-180, 180]. - Returns NULL if the input is NULL or not a valid H3 cell index. - Cell centers are deterministic; the same cell always returns the same longitude. - The returned longitude is not guaranteed to equal the input of H3_LATLNG_TO_CELL because points within a cell share the same cell center. Round-trip precision is bounded by the cell half-width. - The longitude crosses the antimeridian; cells near +/-180 may return values very close to +180 or -180 depending on which side of the boundary the center falls. - No SRID argument is required; coordinates are WGS 84. ## H3 resolution reference | Res | Average edge length | Cell half-width (approx) | | --- | --- | --- | | 0 | 1,107 km | 1,000 km | | 7 | 1.22 km | 1 km | | 9 | 174 m | 150 m | | 12 | 9.4 m | 8 m | | 15 | 0.5 m | 0.4 m | ## Compatibility - Follows the standard H3 hierarchical hex grid specification for cell centroids.
| Name | Type | Description |
|---|---|---|
cell | Specifies the H3 cell index whose center longitude to return. Must be a valid H3 cell. |
-- Round-trip a known point over Paris at resolution 9.
SELECT H3_CELL_TO_LNG(H3_LATLNG_TO_CELL(48.8566, 2.3522, 9)) AS lng;
SELECT
H3_CELL_TO_LAT(c) AS center_lat,
H3_CELL_TO_LNG(c) AS center_lng
FROM (SELECT H3_LATLNG_TO_CELL(34.0522, -118.2437, 8) AS c);
-- Export each H3 bucket as a point with a count for a mapping library.
SELECT
H3_CELL_TO_LNG(h3_cell) AS lng,
H3_CELL_TO_LAT(h3_cell) AS lat,
events
FROM analytics.curated.h3_hourly_counts
WHERE event_date = CURRENT_DATE;
-- Restrict to eastern hemisphere cells.
SELECT h3_cell
FROM analytics.curated.h3_hourly_counts
WHERE H3_CELL_TO_LNG(h3_cell) >= 0;