2

I am trying to understand the behavior of ST_Area() in these examples. I'm using PostGIS 3.2.

In both cases, the polygons are horizontal bands spanning half the globe from the antimeridian to the prime meridian (180 degrees of longitude arc). In the first case, the band spans 30 degrees of latitude arc, but the second is much wider (150 degrees of latitude arc). Results are in million km2.

  1. Why are the reported areas the same for such wildly different polygons?

  2. Also, if the surface area of the entire earth is about 510 million km2, why is ST_Area() returning an area of 255 million km2 for two polygons that are significantly less than half of the earth's surface?

mapping=# SELECT ST_Area(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-180,-15],[-180,15],[0,15],[0,-15],[-180,-15]]]]}')::geography)/1e6/1e6;
      ?column?
--------------------
 255.03281086204427
(1 row)

mapping=# SELECT ST_Area(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-180,-75],[-180,75],[0,75],[0,-75],[-180,-75]]]]}')::geography)/1e6/1e6;
      ?column?
--------------------
 255.03281086204427
(1 row)
3
  • 4
    Perhaps you need to use ST_Segmentize as in this answer: gis.stackexchange.com/a/207183/14766
    – dr_jts
    Nov 9, 2023 at 22:09
  • 1
    See these shapes on a globe here and here
    – Mike T
    Nov 10, 2023 at 9:17
  • Thanks Mike T, I'll bookmark that site. I was mistakenly using geojson.io to visualize these shapes.
    – Matt Skone
    Nov 15, 2023 at 21:42

1 Answer 1

2

Yes, this is the correct answer ... in geography.

Let's not forget that geography uses great circles instead of straight lines to connect two points.

[-180,-15] to [-180,15] ==> the line follows the +-180 meridian, ok.
[-180,15] to [0,15] ==> the line goes to the north pole along the +-180 meridian, then down along the prime meridian.
[0,15] to [0,-15] ==> same thing, the line follows the prime meridian, ok.
[0,-15] to [-180,-15] ==> again, the line goes through the south pole and back on the other side.

No matter which latitude you pick, as long as there is one positive and one negative, since the longitudes are on opposite side of the earth, the great circles will go though the poles and will effectively cut the earth in two.

PS: you can use st_segmentize to illustrate the great circle going through the pole. Let's note that the longitude at the pole is irrelevant.

select st_asText(st_segmentize( 'linestring(-180 75, 0 75)'::geography,1000000));
                                          st_astext
----------------------------------------------------------------------------------------------
 LINESTRING(-180 75,180 82.49999999999999,90 90,3.631996046139919e-15 82.49999999999999,0 75)
1
  • Thanks - makes sense of course. Embarrassingly, I was aware of the great circle behavior but wasn't visualizing it properly in this case.
    – Matt Skone
    Nov 15, 2023 at 21:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.