geo_angle()
Learn how to use the geo_angle() function to calculate the angle between two lines on Earth.
Calculates clockwise angle in radians between two lines on Earth. The first line is [point1, point2] and the second line is [point2, point3].
Syntax
geo_angle(p1_longitude,p1_latitude,p2_longitude,p2_latitude,p3_longitude,p3_latitude)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| p1_longitude | real | ✔️ | The longitude value in degrees of the first geospatial coordinate. A valid value is in the range [-180, +180]. |
| p1_latitude | real | ✔️ | The latitude value in degrees of the first geospatial coordinate. A valid value is in the range [-90, +90]. |
| p2_longitude | real | ✔️ | The longitude value in degrees of the second geospatial coordinate. A valid value is in the range [-180, +180]. |
| p2_latitude | real | ✔️ | The latitude value in degrees of the second geospatial coordinate. A valid value is in the range [-90, +90]. |
| p3_longitude | real | ✔️ | The longitude value in degrees of the second geospatial coordinate. A valid value is in the range [-180, +180]. |
| p3_latitude | real | ✔️ | The latitude value in degrees of the second geospatial coordinate. A valid value is in the range [-90, +90]. |
Returns
An angle in radians in range [0, 2pi) between two lines [p1, p2] and [p2, p3]. The angle is measured CW from the first line to the Second line.
Examples
The following example calculates the angle in radians.
print angle_in_radians = geo_angle(0, 10, 0,5, 3,-10)
Output
| angle_in_radians |
|---|
| 2.94493843406882 |
The following example calculates the angle in degrees.
let angle_in_radians = geo_angle(0, 10, 0,5, 3,-10);
print angle_in_degrees = degrees(angle_in_radians)
Output
| angle_in_degrees |
|---|
| 168.732543198009 |
The following example returns null because 1st point equals to 2nd point.
print is_null = isnull(geo_angle(0, 10, 0, 10, 3, -10))
Output
| is_null |
|---|
| True |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.