H3_CELL_AREA_KM2

Return the exact surface area of an H3 cell in square kilometers on the WGS 84 ellipsoid.

Category: h3Returns: DOUBLEDialect: Standard

Syntax

H3_CELL_AREA_KM2(cell)

Description

## Overview Returns the exact surface area of an H3 cell in square kilometers, measured on the WGS 84 ellipsoid. This is equivalent to H3_CELL_AREA divided by 1,000,000, provided for convenience when reporting at regional or larger scales. Use it for population density calculations, coverage reporting, regional aggregations, and any workflow where kilometers are the natural unit. Like H3_CELL_AREA, this function returns the true area of the specific cell you pass in, including the small per-cell variations that arise from the icosahedral projection and the reduced area of the twelve pentagon cells at each resolution. ## Behavior - Returns a DOUBLE in square kilometers. - Returns NULL if the input is NULL or not a valid H3 cell index. - Equivalent to H3_CELL_AREA(cell) / 1,000,000.0 but avoids a unit-mismatch error at the call site. - Area varies slightly by cell location and is smaller for pentagon cells. - Deterministic: the same cell always returns the same area. - Surface area on the ellipsoid, not a projected 2D area. ## H3 resolution reference | Res | Average edge length | Average hex area | | --- | --- | --- | | 0 | 1,107 km | 4,357,449 km^2 | | 4 | 22.6 km | 1,770 km^2 | | 7 | 1.22 km | 5.16 km^2 | | 9 | 174 m | 0.11 km^2 | | 12 | 9.4 m | 0.0003 km^2 | | 15 | 0.5 m | 0.0000009 km^2 | ## Compatibility - Follows the standard H3 hierarchical hex grid specification.

Parameters

NameTypeDescription
cellSpecifies the H3 cell index to measure. Must be a valid H3 cell produced by a function such as H3_LATLNG_TO_CELL. NULL or invalid cells return NULL.

Examples

-- Resolution 7 cell over London, expect approximately 5 km^2.
SELECT H3_CELL_AREA_KM2(H3_LATLNG_TO_CELL(51.5074, -0.1278, 7)) AS area_km2;
-- Join a population count to an H3 cell and divide by cell area.
SELECT
  h3_cell,
  population,
  population / H3_CELL_AREA_KM2(h3_cell) AS density_per_km2
FROM demographics.curated.h3_population;
SELECT
  H3_CELL_AREA_KM2(H3_LATLNG_TO_CELL(37.7749, -122.4194, 5)) AS res5_km2,
  H3_CELL_AREA_KM2(H3_LATLNG_TO_CELL(37.7749, -122.4194, 7)) AS res7_km2,
  H3_CELL_AREA_KM2(H3_LATLNG_TO_CELL(37.7749, -122.4194, 9)) AS res9_km2;
-- Total km^2 covered by cells that fill a polygon at resolution 7.
SELECT SUM(H3_CELL_AREA_KM2(cell)) AS coverage_km2
FROM (
  SELECT EXPLODE(H3_POLYFILL('POLYGON((-74.10 40.70, -74.10 40.80, -73.90 40.80, -73.90 40.70, -74.10 40.70))', 7)) AS cell
);

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →