The ST_LineFromKML() function

The ST_LineFromKML() function takes a KML LineString string and an optional spatial reference ID and returns a linestring object. A KML LineString string can contain the KML shape attributes <extrude>, <tessellate>, and <altitudeMode>, but they are ignored in the ST_LineString representation.

Syntax

ST_LineFromKML(kmlstring lvarchar)
ST_LineFromKML(kmlstring lvarchar, SRID integer)

Return type

ST_LineString

Example

EXECUTE FUNCTION ST_LineFromKML('<LineString><coordinates>-130.597293,50.678292,
                          0 -129.733457,50.190606,0 -130.509877,49.387208,
                          0 -128.801553,48.669761,0 -129.156745,47.858658,
                         0 -128.717835,47.739997,0</coordinates></LineString>',4);
Output:
(expression)  4 LINESTRING Z (-130.597292947 50.6782919759 0, -129.733456972 
50.1906059982 0, -130.509877068 49.3872080751 0, -128.801553066 48.669761042 0, 
-129.156744951 47.8586579701 0, -128.717834948 47.7399970362 0)