{: .no_toc }
- TOC {:toc}
The problem: calculating the area of a large polygon with straight lines that is converted to a geography
.
Use ST_Segmentize
to add intermediary segments in the lines. This provides a better representation of the geodesic lines in geography.
WITH data(geom) AS (VALUES
( ST_GeomFromEWKT('SRID=4326;POLYGON ((-125 49, -67 49, -67 25, -125 25, -125 49))') )
)
SELECT ST_Area( ST_Segmentize( geom, 0.1)::geography ) AS segarea,
ST_Area( geom::geography ) AS area
FROM data;
Example
SELECT ST_Transform(ST_SetSRID('POINT(575 90)'::geometry,4269),102008);
ERROR: transform: latitude or longitude exceeded limits (-14)
Find geodetic data with invalid coordinates
SELECT * FROM data_tbl
WHERE abs(ST_XMax(geom)) > 180
OR abs(ST_YMax(geom) > 90;