Skip to main content

ST_AREA Geography Functioin Not Providing Correct Answer

  • March 24, 2015
  • 1 reply
  • 10 views

Skala

Hi,

 

I am using ST_Area() geography function for calculation of area under polygon ( specifically speaking  square ) of 3 sq km having each side length of 1.732 km ( root 3 )

 

The sql is - 

VMart=> SELECT ST_Area(ST_GeographyFromText('POLYGON((51.215265136 -179.147338754,51.215265136 -179.122500803037,51.230832300 -179.147338754,51.215265136 -179.147338754))'));
ST_Area
------------------
2390112.44985344
(1 row)

 

On cross verifying the area from google earth and few online tool  

( http://www.daftlogic.com/projects-google-maps-area-calculator-tool.htm  )

the area is found to be ~ 3 sq km as seen in the attched snapshot.

 

What can be the probable reason for NOT getting correct answer by using ST_AREA geography function in vertica ?

 

Kindly suggest/help to utillize this function reliably.

 

With regards,

Vijay

 

1 reply

Ariel_Cary
Forum|alt.badge.img
  • Participating Frequently
  • March 24, 2015

Hi Vijay,

 

There are a couple of problems with your query.
1) The coordinates do not form a rectangular regions. It's missing the NE corner.
2) The coordinate order is inversed. Coordinate data should be entered in (long lat) order. Understandably, this is confusing sometimes as we usually refer to the data as lat/long data.

 

Correcting these problems, I get area value closer to your expected result:

 

SELECT ST_Area(ST_GeographyFromText('POLYGON((-179.147338754 51.215265136, -179.122500803037 51.215265136, -179.122500803037 51.230832300, -179.147338754 51.230832300, -179.147338754 51.215265136))'));
ST_Area
------------------
2994139.65299147
(1 row)

 

Hope this helps.

 

Ariel