Returns the parent grid of an H3-encoded geographic grid at the specified resolution level.
Syntax
h3grid ST_Parent(h3grid code, integer level)Parameters
| Parameter | Description |
|---|---|
code | The H3-encoded geographic grid object. |
level | The resolution level of the parent grid. Lower values represent coarser (larger) grids. Defaults to one level above the resolution of the input grid (immediate parent). |
Examples
These examples use ST_H3FromText to create an H3 grid object from a string, then call ST_Parent to retrieve its parent grid.
-- Return the immediate parent (one level coarser, default behavior)
SELECT ST_AsText(ST_Parent(ST_H3FromText('884a126689fffff')));
ST_AsText
-----------------
874a12668ffffff
-- Return the parent at level 2
SELECT ST_AsText(ST_Parent(ST_H3FromText('884a126689fffff'), 2));
ST_AsText
-----------------
824a17fffffffff