Skip to content
🎉 Apache Sedona 1.8.1 is now available! Check out the new features and improvements.

ST_H3ToGeom

Introduction: Return the result of H3 function cellsToMultiPolygon(cells).

Converts an array of Uber H3 cell indices into an array of Polygon geometries, where each polygon represents a hexagonal H3 cell.

Hint

To convert a Polygon array to MultiPolygon, use ST_Collect. However, the result may be an invalid geometry. Apply ST_MakeValid to the ST_Collect output to ensure a valid MultiPolygon.

An alternative approach to consolidate a Polygon array into a Polygon/MultiPolygon, use the ST_Union function.

Format: ST_H3ToGeom(cells: Array[Long])

Since: v1.6.0

Example:

SELECT ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, true))

Output:

[POLYGON ((1.0057629565405093 1.9984665139177547, 1.0037116327309097 2.0018325249140068, 0.999727799357053 2.001163270465665, 0.9977951427833316 1.997128228393235, 0.9998461908217928 1.993762152933182, 1.0038301712104316 1.9944311839965523, 1.0057629565405093 1.9984665139177547))]