ST_GeodesicLength takes a geometry column and returns a double column that represents the geodesic length of the input geometry. The length is calculated in meters. For point and multipoint geometries this function will always return 0. For polygon geometries this function will return the geodesic length of the perimeter of the polygon. This function is more accurate but less performant than ST_Length and requires that a spatial reference is set on the input geometry column. 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_length.
Examples
from geoanalytics_fabric.sql import functions as ST
# Define input data as text representation of linestring geometry
line_text = 'LINESTRING (-117.61983168124925 34.061452833142205, -117.13262450694835 34.198818997647145, -117.0291395187358 34.01338533049988, -117.53497195243611 33.85262222161066, -117.25919258594303 33.77313917819786, -117.3255236148813 33.65499304933735, -117.54305613040701 33.712919556153935, -117.68800806998975 33.85833780230391, -117.4304999113061 33.968102396479544)'
# Create the geometry DataFrame
df = spark.createDataFrame([(0, line_text)]).toDF("id","line_text") \
.withColumn("line", ST.line_from_text("line_text", 4326))
# Call ST_GeodesicLength using Python syntax and show the result
df.select(ST.geodesic_length(geometry="line").alias("geodesic_length")).show(truncate=False)
+-----------------+
|geodesic_length |
+-----------------+
|230572.5030976661|
+-----------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |