This topic describes the ST_Azimuth function. This function calculates the azimuth from one point to another. The azimuth is an angle that rotates in the clockwise direction starting from the north.
Syntax
float ST_Azimuth(geometry pointA , geometry pointB);
float ST_Azimuth(geography pointA , geography pointB);
Parameters
Parameter | Description |
---|---|
pointA | The first point that you want to specify. |
pointB | The second point that you want to specify. |
Description
- If the points that you specify are coincident, this function returns NULL.
- The azimuth is an angle that is counted starting from the north and is positive in the clockwise direction. The azimuth is 0 on the due north , π/2 on the due east, π on the due south, and 3π/2 on the due west.
Examples
Calculate the azimuth from one point to another by using the default parameter settings.
SELECT degrees(ST_Azimuth('POINT(0 0)'::geometry,'POINT(0 -1)'::geometry));
degrees
---------
180
(1 row)