I am performing a simple calculation on a polygon known to be approximately 6226 km^2 in area. It is stored in a Geography (WGS84 SRID) column.
The query is:
select st_astext(col), st_area(col) area from table
and returns:
"POLYGON((-180 58.282525588539,-178.916399160189 57.4759784390599,-178.191728834624 58.5761461944577,-180 58.282525588539))" | 5807028547.33813
The area returned (5807028547.33813) appears to be mm^2 and not km^2? The documentation http://postgis.net/docs/ST_Area.html states "by default area is determined on a spheroid with units in square meters"
Is this a documentation error, or is the above correct and I'm fundamentally misunderstanding the functionality?
Answer
The calculation gives the right output. As you cited the documentation states "by default area is determined on a spheroid with units in square meters".
The result of your query is 5807028547.33813 m^2. To get the area in km^2 you have to devide the result by 1,000,000.
5807028547.33813 m^2 / 1,000,000 = 5807.02854733813 km^2
5807.02854733813 km^2 corresponds approximately to your expected 6226 km^2.
No comments:
Post a Comment