跳转至
🎉 Apache Sedona 1.9.1 已正式发布!🗺️ 新增 Geography SQL 函数、Box2D 与 Box3D 类型、栅格 Python UDF 等。查看发布说明 →

ST_H3Compact

Introduction: Compacts an array of H3 cell IDs using H3's compactCells(cells).

Complete sets of child cells are replaced by their parents recursively. Cells that cannot be compacted are retained. The result may contain cells at different resolutions and represents the same set of cells when expanded to the original resolution with ST_H3Uncompact.

Input cells must be unique, valid H3 cell IDs at the same resolution. H3 errors are propagated. An empty array returns an empty array, and a null array returns null. The order of the returned cells is not guaranteed.

Format: ST_H3Compact(cells: Array<Long>)

Return type: Array<Long>

Since: v2.0.0

SQL Example

Compact the 49 resolution 7 descendants of a resolution 5 hexagon back to their ancestor:

SELECT ST_H3Compact(ST_H3ToChildren(601041811137363967, 7))

Output:

[601041811137363967]

A single cell is retained:

SELECT ST_H3Compact(ARRAY[601041811137363967])

Output:

[601041811137363967]