All Products
Search
Document Center

PolarDB:ST_GridFromText

Last Updated:Mar 28, 2026

Parses a text-encoded grid code and returns a geomgrid value. Use this function to convert a 2D or 3D grid code string into the geomgrid type required by Ganos spatial grid functions.

Syntax

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

Parameters

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

Examples

Parse a 2D grid code

SELECT ST_GridFromText('G0013103220310313');

Output:

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

Parse a 3D grid code

Wrap the result with ST_AsText to return a human-readable string.

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

Output:

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