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
| Parameter | Description |
|---|---|
start | The starting H3 grid cell. |
end | The 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.