ST_LineFromShape

ST_LineFromShape takes a binary column and returns a linestring column. The input binary column must contain the shapefile 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. If a linestring cannot be created from the input binary the function will return null.

FunctionSyntax
Pythonline_from_shape(shp, sr=None)
SQLST_LineFromShape(shp, sr)
ScalalineFromShape(shp, sr)

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

Examples

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

line_shape = bytearray(b'\x03\x00\x00\x00\\\x8f\xc2\xb5\x0e\x92\\\xc1\n\xd7\xa3\xa0;\xbfSA\xb8\x1e\x85[\xfez\\\xc1R\xb8\x1e\xb5`\xc2SA\x01\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\\\x8f\xc2\xb5\x0e\x92\\\xc1\xaeG\xe1\xeaf\xc1SAH\xe1zD\x1a\x83\\\xc1\n\xd7\xa3\xa0;\xbfSA\xb8\x1e\x85[\xfez\\\xc1R\xb8\x1e\xb5`\xc2SA')

df = spark.createDataFrame([(line_shape,)],["shape"])

df.select(ST.line_from_shape("shape", sr=8857).alias("line_from_shape")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+----------------------------------------------------------------------------------------+
|line_from_shape                                                                         |
+----------------------------------------------------------------------------------------+
|{"paths":[[[-7489594.84,5178779.67],[-7474281.07,5176558.51],[-7465977.43,5179778.83]]]}|
+----------------------------------------------------------------------------------------+

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.