ST_Area

ST_Area takes a geometry column and returns a double column. The output column contains the planar area of each geometry in the input column. The unit of the area calculation is the same as the units of the input geometries. For example, if you have polygons in a spatial reference that uses meters, the result will be in square meters. If your input geometries are in a geographic coordinate system, it is recommended that you use ST_GeodesicArea. Geometry types other than polygon will return 0.0 for the area.

This function may return unexpected results if the input geometries are non-simple. You can check for non-simple geometries using ST_IsSimple and fix your geometries using ST_Simplify. For example, if the input polygon vertices are ordered clockwise, the area result will be negative (for more information see Orientation of a simple polygon). Calling ST_Simplify on the polygon column before calling ST_Area will orient the polygons counterclockwise and produce the expected area result.

FunctionSyntax
Pythonarea(geometry)
SQLST_Area(geometry)
Scalaarea(geometry)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for area.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
from geoanalytics_fabric.sql import functions as ST, Polygon

data = [
    (Polygon([[[0,0],[0,10],[10,10],[10,0],[0,0]]]),),
    (Polygon([[[20,0],[30,20],[40,0],[20,0]]]),),
    (Polygon([[[20,30],[25,35],[30,30],[20,30]]]),)
]
df = spark.createDataFrame(data, ["polygon"])

df.select(ST.area("polygon").alias("st_area")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+-------+
|st_area|
+-------+
|100.0  |
|200.0  |
|25.0   |
+-------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.