Skip to content

Instantly share code, notes, and snippets.

@darrell
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrell/8961708 to your computer and use it in GitHub Desktop.
Save darrell/8961708 to your computer and use it in GitHub Desktop.
What's the best global map projection for calculating area?

What's up with the Gall Stereographic?

Prompted by https://twitter.com/RosemaryDaley/status/433634973061373954, I asked myself how different area calculations would vary by the equal area projection used.

So I grabbed a few equal-area projections to try it out:

  • US National Atlas Equal Area Azimuthal
  • Mollweide
  • Gall Stereographic

For what should be obvious reasons, there's no point in using non-equal area projections.

Using Natural Earth Data in PostGIS 2.0, rounded to km^2:

SELECT  
  name,
  to_char(st_area(st_transform(geom,2163))/ 1000000,'999G999G999') as US_Atlas_Equal_Area,
  to_char(st_area(st_transform(geom,954009))/ 1000000,'999G999G999') as Mollewide,
  to_char(st_area(st_transform(geom,954016))/ 1000000,'999G999G999') as Gall_Stereographic,
  to_char(st_area(geom::geography)/ 1000000,'999G999G999') as wgs84_spheroid
  FROM ne_countries WHERE name like 'A%' or name='United States'
  ORDER BY name;

Produces:

      name           | us_atlas_equal_area |  mollewide   | gall_stereographic | wgs84_spheroid 

-------------------------|---------------------|--------------|--------------------|---------------- Afghanistan | 642,391 | 643,831 | 511,673 | 642,181 Akrotiri | 99 | 99 | 80 | 99 Aland | 937 | 939 | 1,523 | 942 Albania | 28,298 | 28,362 | 25,936 | 28,336 Algeria | 2,312,289 | 2,317,479 | 1,693,571 | 2,308,860 American Samoa | 181 | 181 | 115 | 180 Andorra | 452 | 453 | 427 | 452 Angola | 1,249,421 | 1,252,237 | 784,362 | 1,244,652 Anguilla | 81 | 81 | 53 | 81 Antarctica | 12,258,131 | 12,274,877 | 78,380,097 | nan Antigua and Barb. | 453 | 454 | 294 | 451 Argentina | 2,784,516 | 2,790,757 | 2,310,205 | 2,784,306 Armenia | 29,555 | 29,621 | 26,593 | 29,589 Aruba | 170 | 171 | 107 | 170 Ashmore and Cartier Is. | 3 | 3 | 2 | 3 Australia | 7,705,816 | 7,723,183 | 5,495,078 | 7,691,173 Austria | 83,756 | 83,943 | 89,726 | 83,993 Azerbaijan | 86,153 | 86,346 | 77,525 | 86,250 United States | 9,447,915 | 9,469,111 | 10,008,757 | 9,464,327 (19 rows)

Taking the example of the United States, we can see that there's only a 1 part in 445 difference between the US National Atlas Equal Area and the Mollweide —not to say which is more accurate, but they're pretty consistent.

Side note: apparently PostGIS can't calculate areas on a spheroid when a pole is involved.

If we assume that wgs84_spheroid gives the "right" answer, then what's our deviation from that for each projection? Expressed a 1/percent difference:

SELECT
  name,
  to_char(US_Atlas_Equal_Area/abs(US_Atlas_Equal_Area-wgs84_spheroid), '999G999G999') as US_Atlas_Equal_Area_var,
  to_char(Mollewide/abs(Mollewide-wgs84_spheroid), '999G999G999') as Mollewide_var,
  to_char(Gall_Stereographic/abs(Gall_Stereographic-wgs84_spheroid), '999G999G999') as Gall_Stereographic_var
  FROM areas
  WHERE name LIKE 'A%' or name='United States';

Produces:

     name           | us_atlas_equal_area_var | mollewide_var | gall_stereographic_var 

-------------------------|-------------------------|---------------|------------------------ Afghanistan | 3,065 | 390 | 4 Akrotiri | 8,382 | 424 | 4 Aland | 177 | 294 | 3 Albania | 755 | 1,095 | 11 Algeria | 675 | 269 | 3 American Samoa | 273 | 169 | 2 Andorra | 615 | 1,706 | 17 Angola | 262 | 165 | 2 Anguilla | 320 | 184 | 2 Antarctica | nan | nan | nan Antigua and Barb. | 304 | 181 | 2 Argentina | 13,271 | 433 | 5 Armenia | 882 | 907 | 9 Aruba | 263 | 166 | 2 Ashmore and Cartier Is. | 260 | 165 | 2 Australia | 526 | 241 | 3 Austria | 353 | 1,690 | 16 Azerbaijan | 883 | 902 | 9 United States | 576 | 1,980 | 18 (19 rows)

Because this is the inverse of the difference, bigger is better.

So how do these deviations compare for all 255 countries in Natural Earth?

Let's calculate the median and the average, just for grins:

SELECT 
  to_char(avg(US_Atlas_Equal_Area_var), '999G999G999') as US_avg,
  to_char(median(US_Atlas_Equal_Area_var), '999G999G999') as US_median,
  to_char(avg(Mollewide_var), '999G999G999') as Mollewide_avg,
  to_char(median(Mollewide_var), '999G999G999') as Mollewide_median,
  to_char(avg(Gall_Stereographic_var), '999G999G999') as Gall_avg,
  to_char(median(Gall_Stereographic_var), '999G999G999') as Gall__median 
  FROM (
    SELECT
    name,
    US_Atlas_Equal_Area/abs(US_Atlas_Equal_Area-wgs84_spheroid) as US_Atlas_Equal_Area_var,
    Mollewide/abs(Mollewide-wgs84_spheroid) as Mollewide_var,
    Gall_Stereographic/abs(Gall_Stereographic-wgs84_spheroid) as Gall_Stereographic_var
    FROM areas
    WHERE name <> 'Antarctica' -- leave this out to not have NaN everywhere
    ) deviations;

Produces:

us_avg    |  us_median   | mollewide_avg | mollewide_median |   gall_avg   | gall__median 

--------------|--------------|---------------|------------------|--------------|

   14,984 |          322 |          996  |          223     |            7 |            2

(1 row)

Remember, bigger is better. Drawing conclusions is left as an exercise to the reader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment