ST_GridDistance

更新时间: 2026-03-28 01:57:54

Returns the grid distance between two H3 cells — the minimum number of hops across adjacent cells to travel from one cell to the other.

Syntax

integer ST_GridDistance(h3grid start, h3grid end);

Parameters

ParameterDescription
startThe starting H3 grid cell.
endThe destination H3 grid cell.

Returns

An integer representing the grid distance — the number of grid cells (hops) between the two H3 cells.

Examples

The following example calculates the grid distance between two H3 cells constructed from latitude/longitude coordinates.

SELECT ST_GridDistance(st_h3fromlatlng(25.1, 123.1), st_h3fromlatlng(25.2, 123.2));

Output:

 st_griddistance
-----------------
           17096
(18 rows)

The result 17096 means there are 17,096 grid hops between the two H3 cells.

上一篇: ST_GridPath 下一篇: ST_GridDisk
阿里云首页 云原生数据库 PolarDB 相关技术圈