Name

ST_LineFromText — Returns a LineString object given its Well-known text Representation

Synopsis

geometry ST_LineFromText(varchar WKT);

geometry ST_LineFromText(varchar WKT, integer SRID);

Alias

LineFromText

Description

Creates a LineString from well-known text representation of a LineString and a Spatial Reference System ID (SRID). If the SRID is not provided it defaults to -1. If WKT passed in is not a LINESTRING, then null is returned.

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
3.2.6.27.2.6.1-7.2.8

Examples

--4D Line
SELECT ST_AsEWKT(ST_LineFromText('LINESTRING (0 0 10 8, 0 50 10 18)'));

--Result
LINESTRING (0 0 10 8, 0 50 10 18)

--The input is not a LineString
SELECT ST_AsEWKT(ST_LineFromText('MULTILINESTRING ((0 0 10 8, 0 50 10 18))')) as Line;

--Result
LINE  
null

Related functions

ST_GeomFromText