Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to find out the direction from the 2 points from postGIS database. Please see the attached image. I want to find out the direction from the mainPt to any point. But want to get the result as NW, NE, SE or SW. Simply if I get the degree of the angle it can easily be solved.

Thanksenter image description here

share|improve this question

1 Answer 1

up vote 8 down vote accepted

You could use ST_Azimuth for that : http://postgis.net/docs/ST_Azimuth.html

This will give you an angle in radians and the 0 rad angle stands for a point in the north of your main point

share|improve this answer
2  
Angle is computed clockwise from down-to-up: on the clock: 12=0; 3=PI/2; 6=PI; 9=3PI/2 –  simplexio Mar 14 '13 at 9:44
1  
SELECT ST_Azimuth(ST_Point(90.420408,23.788879), ST_Point(90.419745,23.79009))/(2*pi())*360 as degAz; returning 331.300114079087. But from the Map I am observing that the second point is located NW from the first point. How can I understand the direction? –  Devils Dream Mar 14 '13 at 10:17
1  
According to your example : (0-90°)>NE ; (90-180°)>SE ; (180-270°)>SW ; (270-360°)>NW –  FredB Mar 14 '13 at 10:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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