Enter two points and return the azimuth of the line segment formed by points 1 and 2. Azimuth is the arc of the Angle between the true north line of point 1 and the line segment formed by points 1 and 2.
ST_AZIMUTH( <point1>, <point2>)
| Parameters | Instructions |
|---|---|
<point1> | The first point used to calculate the azimuth |
<point2> | The second point used to calculate the azimuth |
Positive angles are measured clockwise on the sphere. For example, the azimuth of a line segment:
ST_Azimuth has the following edge cases:
SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0));
+----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+
SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0));
+----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+
SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1));
+----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+
SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0));
+--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+