Skip to main content

st_area

Preview

Support for GEOGRAPHY values is in Public Preview. Support for GEOMETRY values is generally available.

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 area is returned (in the unit of the input coordinates, squared). If the input is a geography, area 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)]