[postgis-tickets] [PostGIS] #5238: ST_Area() does not always follow the winding order of coordinates in a Geography
PostGIS
trac at osgeo.org
Mon Sep 12 12:48:22 PDT 2022
#5238: ST_Area() does not always follow the winding order of coordinates in a
Geography
---------------------+---------------------------
Reporter: eldang | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.3.1
Component: postgis | Version: 3.2.x
Keywords: |
---------------------+---------------------------
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:
1. `SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((10 -89.9999, 180
-89.9999, 180 89.9999, 10 89.9999, 10 -89.9999))')) / 1000000;`
2. `SELECT ST_Area(ST_GeogFromText('SRID=4326;POLYGON((0 -89.9999, 180
-89.9999, 180 89.9999, 0 89.9999, 0 -89.9999))')) / 1000000;`
3. `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:
1. Returns approximately 170/360 of the area of the globe in sq km
2. Returns approximately 1/2 of the area of the globe in sq km
3. Returns approximately 190/360 of the area of the globe in sq km
Actual behaviour:
1. 240864321.36968684 (as expected)
2. 255032810.86204427 (as expected)
3. 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.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5238>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list