All Products
Search
Document Center

PolarDB:ST_Parent

Last Updated:Mar 28, 2026

Returns the parent grid of an H3-encoded geographic grid at the specified level.

Syntax

h3grid ST_Parent(h3grid code, integer level)

Parameters

ParameterDescription
codeThe H3-encoded geographic grid object.
levelThe target level of the parent grid. If omitted, defaults to one level above the current level of code.

Examples

Return the immediate parent (default behavior)

Omit the level parameter to get the direct parent at the next coarser level:

SELECT ST_AsText(ST_Parent(ST_H3FromText('884a126689fffff')));

Output:

    st_astext
-----------------
 874a12668ffffff

Return an ancestor at a specific level

Pass a target level to get a coarser ancestor:

SELECT ST_AsText(ST_Parent(ST_H3FromText('884a126689fffff'), 2));

Output:

    st_astext
-----------------
 824a17fffffffff