Del via


st_length

Important

This feature is in Public Preview. You can confirm preview enrollment on the Previews page. See Manage Azure Databricks previews.

Returns the length of the input geometry or geography value.

For the corresponding Databricks SQL function, see st_length function.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.st_length(col=<col>)

Parameters

Parameter Type Description
col pyspark.sql.Column or str A Geography or Geometry value.

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

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()
[Row(result=76.896)]