[GIS] ST_Area and SRID 4326

postgispostgresql

I'm working in the SRID 4326 system and need to compute the area of rectilinear polygons. Our geometry (geom) column is in WKB format

When I execute the ST_Area function it appears my results are returned in squared degrees when I execute a call as follows:

public.ST_Area(geom)/1000000 from production.schemaA where item = '123456'

Then if I cast the geom column to geography the result returned was 33.97 km2

This is still quite a bit off from what I get checking the area of the SAME polygon in Arc Map and QGIS Desktop (Field calculator method) about 43.37 km2

I have investigated using the ST_Transform function to transform out of 4326 but this doesn't work as you have to know which UTM/WGS SRID to use in advance based on the (UTM/ZONE) zone you are working in. We'll be hitting our global database of polygons all over the world had identifying the specific zone is cumbersome.

Example:
public.ST_Area(geom::geography)/1000000 from production.schemaA where item = '123456'

There are threads that are close to this issue but not exactly the same issue of have no solution.

Best Answer

Compare the results from PostGIS with geography:

select ST_Area(
ST_GeogFromText(
'POLYGON ((38.31000000 36.85999999, 38.31000000 36.90999999, 38.38000000 36.90999999, 38.38000000 36.85999999, 38.31000000 36.85999999))'));

34625394.4708328

and with geometry transformed into UTM zone 37 (EPSG:32637):

select ST_Area(
ST_Transform(
ST_GeomFromText(
'POLYGON ((38.31000000 36.85999999, 38.31000000 36.90999999, 38.38000000 36.90999999, 38.38000000 36.85999999, 38.31000000 36.85999999))',4326),32637));


34600605.4910705

Results are about the same, taking into account that UTM has a scale factor of 0.9996. It is unclear in which projection QGIS and ArcMap are computing the areas but the results do not seem to fit well with the ground truth. That's a drawback of software which do clever on-the-fly transformations which can make it hard for the users to know what really happens.