Note
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
Important
This feature is in Public Preview.
Returns the area of the input geography or geometry.
For the corresponding Databricks SQL function, see st_area function.
Syntax
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
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()
[Row(result=27228.52)]
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()
[Row(result=2450.0)]