ST_Linestring takes an array column and returns a linestring column. The input arrays must be arrays of point geometries. The function creates a linestring geometry by connecting the point geometries in the same order that they are stored in the input array.
Function | Syntax |
---|---|
Python | linestring(points) |
SQL | ST |
Scala | linestring(points) |
For more details, go to the GeoAnalytics Engine API reference for linestring.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics.sql import functions as ST, Point
df = spark.createDataFrame([([Point(0, 0), Point(10, 0), Point(20, 0)], )], ["point_array"])
df.select(ST.linestring("point_array").alias("linestring")).show(truncate=False)
+---------------------------------+
|linestring |
+---------------------------------+
|{"paths":[[[0,0],[10,0],[20,0]]]}|
+---------------------------------+
Version table
Release | Notes |
---|---|
1.0.0 | Python and SQL functions introduced |
1.5.0 | Scala function introduced |