ST_H3CellDistance

Introduction: return result of h3 function gridDistance(cel1, cell2). As described by H3 documentation

Finding the distance can fail because the two indexes are not comparable (different resolutions), too far apart, or are separated by pentagonal distortion. This is the same set of limitations as the local IJ coordinate space functions.

In this case, Sedona use in-house implementation of estimation the shortest path and return the size as distance.

Format: ST_H3CellDistance(cell1: Long, cell2: Long)

Return type: Long

Since: v1.5.0

SQL Example

select ST_H3CellDistance(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], ST_H3CellIDs(ST_GeomFromWKT('POINT(1.23 1.59)'), 8, true)[0])

Output:

+-----------------------------------------------------------------------------------------------------------------------------------------+
|st_h3celldistance(st_h3cellids(st_geomfromwkt(POINT(1 2), 0), 8, true)[0], st_h3cellids(st_geomfromwkt(POINT(1.23 1.59), 0), 8, true)[0])|
+-----------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                                                       78|
+-----------------------------------------------------------------------------------------------------------------------------------------+