All Products
Search
Document Center

PolarDB:ST_Level

Last Updated:Mar 28, 2026

Returns the level of a geographic grid. Accepts a single geomgrid, an array of geomgrid objects, or an h3grid.

Syntax

integer   ST_Level(geomgrid  gridcode);
integer[] ST_Level(geomgrid[] gridcode);
integer   ST_Level(h3grid    gridcode);

Parameters

ParameterDescription
gridcodeThe geographic grid object. Accepts a geomgrid, a geomgrid array, or an h3grid.

Return values

Input typeReturn typeDescription
geomgridintegerThe level of the grid.
geomgrid[]integer[]The level range across all grids in the array, returned as {min, max}.
h3gridintegerThe level of the H3 grid cell.

Examples

-- geomgrid (string input)
SELECT ST_Level(ST_GridFromText('GZ0026206440'));
 st_level
----------
       10

-- geomgrid array (3D geometry with holes)
SELECT ST_Level(ST_As3DGrid('srid=4490;GEOMETRYCOLLECTION Z (MULTIPOLYGON Z (((116 39 5000,116.12 39 5000,116.12 39.09 5000,116 39.09 5000,116 39 5000),
(116.024 39.018 5000,116.024 39.045 5000,116.06 39.045 5000,116.06 39.018 5000,116.024 39.018 5000))),
POINT Z (116 39 5000),MULTILINESTRING Z ((116 39 5000,116.024 39 5000),(116.012 39.009 5000,116.024 39.018 5000)),
POLYHEDRALSURFACE Z (((116 39 0,116 39 1000,116 39.009 0,116 39 0)),((116 39 0,116 39.009 0,116.012 39 0,116 39 0)),
((116 39 0,116.012 39 0,116 39 1000,116 39 0)),((116.012 39 0,116 39.009 0,116 39 1000,116.012 39 0))))'::geometry,
20,true));
 st_level
----------
 {19,20}

-- H3 grid (binary input)
SELECT ST_Level(ST_H3FromBinary('\x010100ffff9f6826a18408'));
 st_level
----------
        8

See also