ST_GeodesicLength

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.

FunctionSyntax
Pythongeodesic_length(geometry)
SQLST_GeodesicLength(geometry)
ScalageodesicLength(geometry)

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

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
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)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------+
|geodesic_length  |
+-----------------+
|230572.5030976661|
+-----------------+

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.