Returns the parent grid of an H3-encoded geographic grid at the specified level.
Syntax
h3grid ST_Parent(h3grid code, integer level)Parameters
| Parameter | Description |
|---|---|
code | The H3-encoded geographic grid object. |
level | The 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
-----------------
874a12668ffffffReturn 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