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

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

Example:

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

Output:

+----+----------------------+
| op |               EXPR$0 |
+----+----------------------+
| +I |                   78 |
+----+----------------------+

ST_H3CellDistance