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

SQL Example

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

Output:

+--------------------------------------------------------------------------------------------------------------------------------------------+
|cells                                                                                                                                       |
+--------------------------------------------------------------------------------------------------------------------------------------------+
|[614552597293957119, 614552609329512447, 614552609316929535, 614552609327415295, 614552609287569407, 614552597289762815]                    |
|[614552609325318143, 614552597293957119, 614552609329512447, 614552609316929535, 614552609327415295, 614552609287569407, 614552597289762815]|
+--------------------------------------------------------------------------------------------------------------------------------------------+