#5238 closed defect (wontfix)
ST_Area() does not always follow the winding order of coordinates in a Geography
Reported by: | eldang | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.2.4 |
Component: | postgis | Version: | 3.2.x |
Keywords: | Cc: | eldang |
Description
The area reported by ST_Area()
for a Geography created from coordinates that span > 180 degrees of longitude falls short, with a pattern that suggests the polygon may be getting interpreted as going the wrong way around the globe.
Repro steps:
SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((10 -89.9999, 180 -89.9999, 180 89.9999, 10 89.9999, 10 -89.9999))')) / 1000000;
SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((0 -89.9999, 180 -89.9999, 180 89.9999, 0 89.9999, 0 -89.9999))')) / 1000000;
SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((-10 -89.9999, 180 -89.9999, 180 89.9999, -10 89.9999, -10 -89.9999))')) / 1000000;
Expected behaviour:
- Returns approximately 170/360 of the area of the globe in sq km
- Returns approximately ½ of the area of the globe in sq km
- Returns approximately 190/360 of the area of the globe in sq km
Actual behaviour:
- 240864321.36968684 (as expected)
- 255032810.86204427 (as expected)
- Returns exactly the same as the first test
I have seen this in the wild with more complex polygons, which were getting suspiciously low areas returned. The above example is the simplest case I can reproduce it with. I do get the same behaviour if I offset the polygon to avoid the antimeridian (e.g. SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((-80 -89.9999, 90 -89.9999, 90 89.9999, -80 89.9999, -80 -89.9999))')) / 1000000;
)
This does not affect multipolygons as long as each individual Polygon component spans < 180 degrees of longitude. As a result I do have a relatively straightforward workaround for my own use, of simply splitting polygons wider than that to calculate their area. But it is a very unexpected behaviour.
Change History (3)
comment:1 by , 2 years ago
Milestone: | PostGIS 3.3.1 → PostGIS 3.2.4 |
---|
follow-up: 3 comment:2 by , 2 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 2 years ago
Replying to robe:
This is by design. geography doesn't care about winding order and always computes based on short-test edge. It does not support correctly calculate measures of geometries larger than a half-hemisphere as a result.
This is written in the FAQ - https://postgis.net/docs/using_postgis_dbmanagement.html#idm1655
Thank you, and I'm sorry I hadn't realised that.
This is by design. geography doesn't care about winding order and always computes based on short-test edge. It does not support correctly calculate measures of geometries larger than a half-hemisphere as a result.
This is written in the FAQ - https://postgis.net/docs/using_postgis_dbmanagement.html#idm1655