ST_Azimuth
Syntax
DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)
description
Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2.
The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment:
- Pointing North is 0
- Pointing East is PI/2
- Pointing South is PI
- Pointing West is 3PI/2
ST_Azimuth has the following edge cases:
- If the two input points are the same, returns NULL.
- If the two input points are exactly antipodal, returns NULL.
- If either of the input geographies are not single points or are the empty geography, throws an error.
example
1. mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0));
2. +----------------------------------------------------+
3. | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) |
4. +----------------------------------------------------+
5. | 4.71238898038469 |
6. +----------------------------------------------------+
7. 1 row in set (0.03 sec)
9. mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0));
10. +----------------------------------------------------+
11. | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) |
12. +----------------------------------------------------+
13. | 1.5707963267948966 |
14. +----------------------------------------------------+
15. 1 row in set (0.01 sec)
17. mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1));
18. +----------------------------------------------------+
19. | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) |
20. +----------------------------------------------------+
21. | 0 |
22. +----------------------------------------------------+
23. 1 row in set (0.01 sec)
25. mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1));
26. +----------------------------------------------------+
27. | st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) |
28. +----------------------------------------------------+
29. | NULL |
30. +----------------------------------------------------+
31. 1 row in set (0.02 sec)
33. mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0));
34. +--------------------------------------------------------+
35. | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) |
36. +--------------------------------------------------------+
37. | NULL |
38. +--------------------------------------------------------+
39. 1 row in set (0.02 sec)
keywords
ST_AZIMUTH,ST,AZIMUTH
