st_length
Preview
This feature is in Public Preview. You can confirm preview enrollment on the Previews page. See Manage Databricks previews.
Returns the length of the input geometry or geography value.
For the corresponding Databricks SQL function, see st_length function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_length(col=<col>)
Parameters
Notes
If the input is a geometry, Cartesian length is returned (in the unit of the input coordinates). If the input is a geography, length on the WGS84 spheroid is returned (expressed in meters).
Examples
Python
from pyspark.databricks.sql import functions as dbf
from pyspark.sql.functions.builtin import round
df = spark.createDataFrame([('LINESTRING(10 34,44 57,30 24)',)], ['wkt'])
df.select(round(dbf.st_length(dbf.st_geomfromtext('wkt')), 3).alias('result')).collect()
Output
[Row(result=76.896)]