Opened 13 years ago

Closed 13 years ago

#1154 closed defect (wontfix)

ST_Area returns wrong results for big geography polygon [-179.9 -89.9 179.9 89.9 ]

Reported by: mvimercati Owned by: pramsey
Priority: high Milestone:
Component: postgis Version: 1.5.X
Keywords: ST_Area geography big huge area Cc:

Description

Seems that ST_Area has some problem calculating very big area, like global area [ minlon=-179.9 minlat=-89.9 maxlon=179.9 maxlat=89.9 ]. I remember earth areas is about 510348973 km2

This calculates the area of half earth (near, I'm not crossing dateline), and seems correct

select st_area(g)/1000000, st_area(transform(geometry(g), 4326)),astext(geometry(g)) from (select 'POLYGON((0 89.9, 179.9 89.9, 179.9 -89.9, 0 -89.9, 0 89.9))'::geography) as foo(g); 
     ?column?     | st_area  |                         astext                          
------------------+----------+---------------------------------------------------------
 255174486.625509 | 32346.02 | POLYGON((0 89.9,179.9 89.9,179.9 -89.9,0 -89.9,0 89.9))

where the whole globe gives strange result:

st_area(transform(geometry(g), 4326)),astext(geometry(g)) from (select 'POLYGON((-179.9 89.9, 179.9 89.9, 179.9 -89.9, -179.9 -89.9, -179.9 89.9))'::geography) as foo(g); 
     ?column?     | st_area  |                                 astext                                 
------------------+----------+------------------------------------------------------------------------
 283369.499733791 | 64692.04 | POLYGON((-179.9 89.9,179.9 89.9,179.9 -89.9,-179.9 -89.9,-179.9 89.9))

I'm running Postgis 1.5.3 on Postgres 9.0.4. Arch Linux 64bit

Best Regards Vime

Change History (1)

comment:1 by robe, 13 years ago

Resolution: wontfix
Status: newclosed

Vime,

I believe this is an implementation limitation. The geography type is not guaranteed to be right for arcs greater than a half hemispherre. In fact is pretty guaranteed to be wrong for calculations for geographies with arcs greater than 180. That's a limitation of it because of the way calculations are done. This is known and don't think we plan to fix this in the forseeable near feature.

Take a look at the FAQ: #4.2.3.3 for details: http://www.postgis.org/documentation/manual-svn/using_postgis_dbmanagement.html#PostGIS_Geography_AdvancedFAQ

If I misunderstood you, please feel free to reopen this ticket.

Note: See TracTickets for help on using tickets.