ST_Area — Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.
float ST_Area(
geometry g1)
;
float ST_Area(
geography geog, boolean use_spheroid=true)
;
Returns the area of the geometry if it is a polygon or multi-polygon. Return the area measurement of an ST_Surface or ST_MultiSurface value. For geometry Area is in the units of the srid. For geography area is in square meters and defaults to measuring about the spheroid of the geography (currently only WGS84). To measure around the faster but less accurate sphere -- ST_Area(geog,false).
Enhanced: 2.0.0 - support for 2D polyhedral surfaces was introduced.
This method implements the OpenGIS Simple Features Implementation Specification for SQL 1.1.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.2, 9.5.3
This function supports Polyhedral surfaces.
For polyhedral surfaces, only supports 2D polyhedral surfaces (not 2.5D). For 2.5D, may give a non-zero answer, but only for the faces that sit completely in XY plane. |
Return area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters. Note this is in square feet because 2249 is Mass State Plane Feet
SELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqm FROM (SELECT ST_GeomFromText('POLYGON((743238 2967416,743238 2967450, 743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom); sqft | sqm ---------+------------- 928.625 | 86.27208552
Return area square feet and transform to Massachusetts state plane meters (26986) to get square meters. Note this is in square feet because 2249 is Mass State Plane Feet and transformed area is in square meters since 26986 is state plane mass meters
SELECT ST_Area(the_geom) As sqft, ST_Area(ST_Transform(the_geom,26986)) As sqm FROM (SELECT ST_GeomFromText('POLYGON((743238 2967416,743238 2967450, 743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom); sqft | sqm ---------+------------------ 928.625 | 86.2724304199219
Return area square feet and square meters using Geography data type. Note that we transform to our geometry to geography (before you can do that make sure your geometry is in WGS 84 long lat 4326). Geography always measures in meters. This is just for demonstration to compare. Normally your table will be stored in geography data type already.
SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft_spheroid, ST_Area(the_geog,false)/POWER(0.3048,2) As sqft_sphere, ST_Area(the_geog) As sqm_spheroid FROM (SELECT geography( ST_Transform( ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))', 2249 ) ,4326 ) ) ) As foo(the_geog); sqft_spheroid | sqft_sphere | sqm_spheroid -----------------+------------------+------------------ 928.684405217197 | 927.186481558724 | 86.2776044452694 --if your data is in geography already SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft, ST_Area(the_geog) As sqm FROM somegeogtable;