All Products
Search
Document Center

PolarDB:ST_GridDistance

Last Updated:Mar 28, 2026

Returns the grid distance between two H3 grid objects.

Syntax

integer ST_GridDistance(h3grid start, h3grid end);

Parameters

ParameterDescription
startThe starting H3 grid object.
endThe ending H3 grid object.

Return value

Returns an integer representing the distance between start and end.

Examples

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

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

Output:

 st_griddistance
-----------------
           17096