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
.
Function | Syntax |
---|---|
Python | line |
SQL | ST |
Scala | line |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for line_from_shape.
Examples
from geoanalytics_fabric.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
+----------------------------------------------------------------------------------------+
|line_from_shape |
+----------------------------------------------------------------------------------------+
|{"paths":[[[-7489594.84,5178779.67],[-7474281.07,5176558.51],[-7465977.43,5179778.83]]]}|
+----------------------------------------------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |