All Products
Search
Document Center

PolarDB:ST_GridFromText

Last Updated:Mar 28, 2026

Converts a grid code string into a geomgrid (GeomGrid) structure. Use the two-argument form to parse 3D grid codes that include a height component.

Syntax

geomgrid ST_GridFromText(text XYCode);
geomgrid ST_GridFromText(text XYCode, text ZCode);

Parameters

ParameterDescription
XYCodeThe 2D grid code in string format.
ZCodeThe height code in 3D grid split encoding.

Examples

Parse a 2D grid code:

SELECT ST_GridFromText('G0013103220310313');

Output:

   st_gridfromtext
----------------------
 0102001074271B122020

Parse a 3D grid code with a height component, and return the result as text:

SELECT ST_AsText(ST_GridFromText('G00131032223023031031','+10010'));

Output:

       st_astext
------------------------
 GZ00262064446046072072