返回給定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)