Skip to main content

st_area

Preview

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

Returns the area of the input geography or geometry.

For the corresponding Databricks SQL function, see st_area function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.st_area(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 sq. meters).

Examples

Python
from pyspark.databricks.sql import functions as dbf
from pyspark.sql.functions.builtin import round
df = spark.createDataFrame([('POLYGON((0 0,50 0,50 50,0 50,0 0),(20 20,25 30,30 20,20 20))',)], ['wkt'])
df.select(round(dbf.st_area(dbf.st_geogfromtext('wkt')) / 1e9, 2).alias('result')).collect()
Output
[Row(result=27228.52)]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POLYGON((0 0,50 0,50 50,0 50,0 0),(20 20,25 30,30 20,20 20))',)], ['wkt'])
df.select(dbf.st_area(dbf.st_geomfromtext('wkt', 4326)).alias('result')).collect()
Output
[Row(result=2450.0)]