This function converts a grid object into text that is encoded in a specified specification.

Syntax

text ST_AsText(geomgrid    grid,
               integer precision,
               text standard default 'GGER')
text[] ST_AsText(geomgrid[]    grid,
               integer precision,
               text standard default 'GGER')

Parameters

Parameter Description
grid The grid object to be generated.
precision The precision level. Valid values: 0 to 31. The value -1 indicates that the default precision level is used.
standard The specification standard: GeoSpatial Grid Encoding Rule (GGER). It is developed by the Ministry of Natural Resources of the People's Republic of China. Default value: GGER.

Description

The grid object is generated based on the specified layer, precision, and encoding specification. If the specified precision is higher than the precision of the stored grid, the system does not fill zeros for output.

Examples

--Use the default layer.
with g as (
  select unnest(st_asgrid(
    ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490), 15)) as grid) 
select ST_asText(grid) from g;

    st_astext     
------------------
 G001310322230230

--Specify the output layer.
with g as (
  select unnest(st_asgrid(
    ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490), 15)) as grid) 
select ST_asText(grid, 8) from g;

  st_astext  
-------------
 G01310322