ST_ShortestLine

ST_ShortestLine takes two geometry columns and returns a linestring column. The output column contains the shortest line that touches two geometries, using planar 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. If the two geometry columns are in different spatial references, the function automatically transforms the second geometry into the spatial reference of the first.

If your input geometries are in a geographic coordinate system, consider using ST_GeodesicShortestLine to identify the shortest line.

FunctionSyntax
Pythonshortest_line(geometry1, geometry2)
SQLST_ShortestLine(geometry1, geometry2)
ScalashortestLine(geometry1, geometry2)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for shortest_line.

Examples

PythonPythonSQLScala
1
2
3
4
5
6
7
8
9
10

from geoanalytics_fabric.sql import functions as ST

line_text = 'LINESTRING (30 10, 30 40)'

df = spark.createDataFrame([(line_text, 20, 25)], ["wkt", "lon", "lat"]) \
          .withColumn("line", ST.line_from_text("wkt")) \
          .withColumn("point", ST.point("lon", "lat"))

df.select(ST.shortest_line("line", "point").alias("shortest_line")).show(truncate = False)
Result
1
2
3
4
5
+-----------------------------+
|shortest_line                |
+-----------------------------+
|{"paths":[[[30,25],[20,25]]]}|
+-----------------------------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

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

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close