How can I find the bearing between two points in PostGIS?
Please specify in your answer whether or not the method producing a bearing on the spheroid, or a planar bearing.
|
|
Using ST_AzimuthPlanar bearing can be calculated using
For spherical azimuth (Quoting potgis-users group):
Using trigonometric functions and ST_distance_sphereThis is the solution I've chosen when I had to deal with this problems, mainly for legacy reasons (I had a Python function which calculates the azimuth). First, we need to find a function that would tell us the exact distance between two points. Quoting the postgis manual:
Measure the Longitude and Latitude distance between the points, and use the |
|||||
|
|
For anyone coming across this question now - PostGIS supports ST_Azimuth on geography (spheroid) as of 2.0.0. |
|||
|
|