ST_Area
Calculates the area of a spatial object.
The units are:
- GEOMETRY objects: spatial reference system identifier (SRID) units
- GEOGRAPHY objects: square meters
Behavior Type
Syntax
ST_Area( g )
Arguments
g |
Spatial object for which you want to calculate the area, type GEOMETRY or GEOGRAPHY |
Returns
FLOAT
Supported Data Types
Data Type | GEOMETRY | GEOGRAPHY (Perfect Sphere) |
Point | Yes |
Yes |
Multipoint |
Yes |
Yes |
Linestring | Yes | Yes |
Multilinestring | Yes | Yes |
Polygon | Yes | Yes |
Multipolygon | Yes | Yes |
GeometryCollection | Yes | No |
Examples
The following examples show how to use ST_Area.
Calculate the area of a polygon:
=> SELECT ST_Area(ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))')); ST_Area --------- 1 (1 row)
Calculate the area of a multipolygon:
=> SELECT ST_Area(ST_GeomFromText('MultiPolygon(((0 0,1 0,1 1,0 1,0 0)), ((2 2,2 3,4 6,3 3,2 2)))'));
ST_Area
---------
3 (1 row)
Suppose the polygon has a hole, as in the following figure.
Calculate the area, excluding the area of the hole:
=> SELECT ST_Area(ST_GeomFromText('POLYGON((2 2,5 5,8 2,2 2), (4 3,5 4,6 3,4 3))')); ST_Area --------- 8 (1 row)
Calculate the area of a geometry collection:
=> SELECT ST_Area(ST_GeomFromText('GEOMETRYCOLLECTION(POLYGON((20.5 20.45, 20.51 20.52,20.69 20.32,20.5 20.45)),POLYGON((10 20,30 40,25 50,10 20)))')); ST_Area ---------- 150.0073 (1 row)
Calculate the area of a geography object:
=> SELECT ST_Area(ST_GeographyFromText('POLYGON((20.5 20.45,20.51 20.52, 20.69 20.32,20.5 20.45))')); ST_Area ------------------ 84627437.116037 (1 row)