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

ST_H3KRing

Introduction: return the result of H3 function gridDisk(cell, k).

K means the distance of the origin index, gridDisk(cell, k) return cells with distance <=k from the original cell.

exactRing : Boolean, when set to true, sedona will remove the result of gridDisk(cell, k-1) from the original results, means only keep the cells with distance exactly k from the original cell

Format: ST_H3KRing(cell: Long, k: Int, exactRing: Boolean)

Since: v1.5.0

Example:

select ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 1, false), ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 1, true)

Output:

+----+--------------------------------+--------------------------------+
| op |                         EXPR$0 |                         EXPR$1 |
+----+--------------------------------+--------------------------------+
| +I | [614552609325318143, 614552... | [614552597293957119, 614552... |
+----+--------------------------------+--------------------------------+