ST_GeodesicShortestLine takes two geometry columns and returns a linestring column. The output column contains the shortest line that touches two geometries, using geodesic distance calculation. This function returns only one shortest line if there are more than one. If the two input geometries intersect, an empty line geometry is returned.
This function is more accurate but less performant than ST_ShortestLine and requires that a spatial reference is set on the input geometry column. If the two geometry columns are in different spatial references, the function automatically transforms the second geometry into the spatial reference of the first. To learn more about the difference between planar and geodesic calculations, see Coordinate systems and transformations.
Function | Syntax |
---|---|
Python | geodesic |
SQL | ST |
Scala | geodesic |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for geodesic_shortest_line.
Examples
from geoanalytics_fabric.sql import functions as ST
line_text = 'LINESTRING (-117.61983168124925 34.061452833142205, -117.13262450694835 34.198818997647145, -117.0291395187358 34.01338533049988)'
point_text = 'POINT (-117.34805417060637 34.00267278771285)'
df = spark.createDataFrame([(line_text, point_text)], ["line_wkt", "point_wkt"]) \
.withColumn("line", ST.line_from_text("line_wkt", 4326)) \
.withColumn("point", ST.point_from_text("point_wkt", 4326))
df.select(ST.geodesic_shortest_line("line", "point").alias("geodesic_shortest_line")).show(truncate = False)
+---------------------------------------------------------------------------------------------+
|geodesic_shortest_line |
+---------------------------------------------------------------------------------------------+
|{"paths":[[[-117.39749505040815,34.12413977992499],[-117.34805417060637,34.00267278771285]]]}|
+---------------------------------------------------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |