ST_LineFromText

更新时间:
复制 MD 格式

Constructs a LineString geometry from a Well-Known Text (WKT) string and an optional spatial reference identifier (SRID).

Syntax

geometry ST_LineFromText(text wKT);
geometry ST_LineFromText(text wKT, integer srid);

Parameters

ParameterTypeDescription
wKTtextThe WKT representation of the LineString.
sridintegerThe SRID to assign to the geometry. Defaults to 0 if not specified.

Usage notes

  • If the WKT string does not represent a LineString, the function returns NULL.

  • If you omit srid, the geometry is assigned SRID 0.

Examples

SELECT ST_AsText(ST_LineFromText('LINESTRING(1 2, 3 4)'));
      st_astext
---------------------
 LINESTRING(1 2,3 4)
(1 row)