ST_LineFromText

ST_LineFromText takes a string column and returns a linestring column. The string column must contain the well-known text (WKT) representation of linestring geometries. You can optionally specify a spatial reference for the result linestring column. The sr parameter value must be a valid SRID or WKT string.

FunctionSyntax
Pythonline_from_text(wkt, sr=None)
SQLST_LineFromText(wkt, sr)
ScalalineFromText(wkt, sr)

For more details, go to the GeoAnalytics Engine API reference for line_from_text.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
from geoanalytics.sql import functions as ST, Polygon, Point

data = [("LINESTRING (-3636954.77 7750916.26, -3168756.90 7966747.98, -3124795.45 7893415.62)", )]

df = spark.createDataFrame(data, ["wkt"])

df.select(ST.line_from_text("wkt", sr=8857).alias("line_from_text")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+---------------------------------------------------------------------------------------+
|line_from_text                                                                         |
+---------------------------------------------------------------------------------------+
|{"paths":[[[-3636954.77,7750916.26],[-3168756.9,7966747.98],[-3124795.45,7893415.62]]]}|
+---------------------------------------------------------------------------------------+

Version table

ReleaseNotes

1.0.0

Python and SQL functions introduced

1.5.0

Scala function introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.