文档

ST_AsText

更新时间:

返回给定Geometry对象或Geography对象的WKT表示,不包含SRID元数据。

语法

text ST_AsText(geometry g1);
text ST_AsText(geometry g1 , integer maxdecimaldigits);
text ST_AsText(geography g1);
text ST_AsText(geography g1 , integer maxdecimaldigits);

参数

参数名称

描述

g1

目标Geometry/Geography对象。

maxdecimaldigits

最大小数位数。默认为15。

描述

  • 要将SRID作为数据的一部分,请使用非标准的ST_AsEWKT函数。

  • WKT格式不能保持精度,因此为了防止浮点值截断,请使用ST_AsBinaryST_AsEWKB格式进行传输。

示例

  • 默认调用:

    SELECT ST_AsText(ST_GeomFromText('POINT(116 40)',4326));
       st_astext
    ---------------
     POINT(116 40)
    (1 row)
  • 指定位数:

    SELECT ST_AsText(ST_GeomFromText('POINT(116.112 40.412)',4326),2);
          st_astext
    ---------------------
     POINT(116.11 40.41)
    (1 row)
  • 本页导读 (1)
文档反馈