Muokkaa

Jaa


geo_azimuth()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Calculates clockwise angle in radians between the line from point1 to true north and a line from point1 to point2 on Earth.

Syntax

geo_azimuth(p1_longitude,p1_latitude,p2_longitude,p2_latitude)

Learn more about syntax conventions.

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].

Returns

An angle in radians between the line from point p1 to true north and line [p1, p2]. The angle is measured clockwise.

Note

  • The geospatial coordinates are interpreted as represented by the WGS-84 coordinate reference system.
  • The geodetic datum used to measure distance on Earth is a sphere. Line edges are geodesics on the sphere.
  • Azimuth 0 points north. Azimuth Pi/2 points east. Azimuth Pi points south. Azimuth 3Pi/2 points west.
  • If the coordinates are invalid, the query will produce a null result.
  • If point1 is equal to point2, the query will produce a null result.
  • If point1 and point2 are antipodal, the query will produce a null result.

Examples

The following example calculates azimuth in radians.

print azimuth_in_radians = geo_azimuth(5, 10, 10, -40)

Output

azimuth_in_radians
3.05459939796449

The following example calculates azimuth in degrees.

let azimuth_in_radians = geo_azimuth(5, 10, 10, -40);
print azimuth_in_degrees = degrees(azimuth_in_radians);

Output

azimuth_in_degrees
175.015653606568

The following example considers a truck that emits telemetry of its location while it travels and looks for its travel direction.

let get_direction = (azimuth:real)
{
    let pi = pi();
    iff(azimuth < pi/2,   "North-East",
    iff(azimuth < pi,     "South-East",
    iff(azimuth < 3*pi/2, "South-West",
                          "North-West")));
};
datatable(timestamp:datetime, lng:real, lat:real)
[
    datetime(2024-01-01T00:01:53.048506Z), -115.4036607693417, 36.40551631046261,
    datetime(2024-01-01T00:02:53.048506Z), -115.3256807623232, 36.34102142760111,
    datetime(2024-01-01T00:03:53.048506Z), -115.2732290602112, 36.28458914829917,
    datetime(2024-01-01T00:04:53.048506Z), -115.2513186233914, 36.27622394664352,
    datetime(2024-01-01T00:05:53.048506Z), -115.2352055633212, 36.27545547038515,
    datetime(2024-01-01T00:06:53.048506Z), -115.1894341934856, 36.28266934431671,
    datetime(2024-01-01T00:07:53.048506Z), -115.1054318118468, 36.28957085435267,
    datetime(2024-01-01T00:08:53.048506Z), -115.0648614339413, 36.28110743285072,
    datetime(2024-01-01T00:09:53.048506Z), -114.9858032867736, 36.29780696509714,
    datetime(2024-01-01T00:10:53.048506Z), -114.9016966527561, 36.36556196813566,
]
| sort by timestamp asc 
| extend prev_lng = prev(lng), prev_lat = prev(lat)
| where isnotnull(prev_lng) and isnotnull(prev_lat)
| extend direction = get_direction(geo_azimuth(prev_lng, prev_lat, lng, lat))
| project direction, lng, lat
| render scatterchart with (kind = map)

Output

Azimuth between two consecutive locations.

The following example returns true because the first point equals the second point.

print is_null = isnull(geo_azimuth(5, 10, 5, 10))

Output

is_null
true