Polygon area

The area of a polygon or MultiPolygon geometry is computed with the ST_Area function. The same rules that we used with the perimeter calculations apply: when the argument is of the geometry type, the planimetric variant will be used, and with the geography type, the geodesic variant will be used:

SELECT ST_Area(ST_GeomFromText('POLYGON((391390 5817855,391490 5817955,391590 5818055, 319590 5817855,391390 5817855))', 32633));
st_area
---------
7180000

The argument is of the geometry type, and the SRID is 32633, which leads us to UTM 33N. The result is given in square meters:

    SELECT ST_Area(
ST_MakePolygon(ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98), ST_MakePoint(19.90,49.90),ST_MakePoint(20,50)]))::geography
);

st_area
------------------
11949254.7990036

The argument is of the geography type, so the result will be computed geodesically with the units as square meters.

Finally, for polygons with holes, the interior rings' area is subtracted from the exterior rings' area:

    SELECT ST_Area(ST_MakePolygon(
ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98), ST_MakePoint(19.90,49.90),ST_MakePoint(20,50)]),
ARRAY[ST_MakeLine(ARRAY[ST_MakePoint(19.95,49.97),ST_MakePoint(19.943,49.963), ST_MakePoint(19.955,49.965),ST_MakePoint(19.95,49.97)])]
)::geography);

st_area
------------------
11669942.4506721
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset