ST_FréchetDistance

ST_FréchetDistance takes two linestring columns and returns a double column. The output column represents the discrete Fréchet distance between the two input linestrings.

The calculation spatially aligns vertices in the first input linestring to the closest vertices in the second input linestring. The discrete Fréchet distance is the greatest distance among all aligned pair of vertices.

ST_FréchetDistance
Two linestrings (orange and blue). A distance (red line) is calculated between the closest vertices in the two linestrings. The green line is the discrete Fréchet distance.

For more details on the discrete Fréchet distance calculation, see Computing Discrete Fréchet Distance.

The result will be in the same units as the input geometry data. For example, if the input geometries are in a spatial reference that uses meters, the result values will be in meters.

If the two geometry columns are in different spatial references, the function will automatically transform the second geometry into the spatial reference of the first.

If one of the input geometries has an unknown spatial reference the function will use planar distance calculations.

ST_FréchetDistance does not take m-values and z-values into account. If the input linestring has any of these values, they will be ignored in the Fréchet distance calculation.

The function can be used with or without the diacritic, ST_FrechetDistance and ST_FréchetDistance are both valid ways to use the function.

ST_FréchetDistance can be used to measure the similarity between two linestrings. For more details, go to the core topic for similarity measures.

FunctionSyntax
Pythonfrechet_distance(linestring1, linestring2)
SQLST_FrechetDistance(linestring1, linestring2)
ScalafrechetDistance(linestring1, linestring2)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for fréchet_distance.

Examples

PythonPythonSQLScala
1
2
3
4
5
6
7
8
9
10
11
12
13

from geoanalytics_fabric.sql import functions as ST, Linestring

data = [
    ("LINESTRING (10 10, 20 20)", "LINESTRING (10 30, 20 40)"),
    ("LINESTRING (0 20, 10 20)", "LINESTRING (0 80, -10 20)")
]

df = spark.createDataFrame(data, ["line1_wkt", "line2_wkt"]) \
          .withColumn("line1", ST.line_from_text("line1_wkt", 4326)) \
          .withColumn("line2", ST.line_from_text("line2_wkt", 4326))

df.select(ST.frechet_distance("line1", "line2").alias("frechet_distance")).show()
Result
1
2
3
4
5
6
+----------------+
|frechet_distance|
+----------------+
|            20.0|
|            60.0|
+----------------+

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