Main Content

azimuth

Azimuth between points on sphere or ellipsoid

    Description

    az = azimuth(lat1,lon1,lat2,lon2) calculates the great circle azimuth from the point with geographic coordinates lat1 and lon1 to the point with geographic coordinates lat2 and lon2. The function measures azimuths clockwise from north. This syntax references the coordinates to a sphere and returns az in degrees.

    example

    az = azimuth(lat1,lon1,lat2,lon2,ellipsoid) specifies a reference ellipsoid for the coordinates.

    example

    az = azimuth(___,units) specifies the angle units for the coordinates and azimuth, in addition to any combination of input arguments from the previous syntaxes.

    az = azimuth(method,___), where method is "rh", calculates the rhumb line azimuth between the points. The default for method is "gc", which calculates the great circle azimuth (for a sphere) or the geodesic azimuth (for an ellipsoid).

    example

    Examples

    collapse all

    Find the azimuth between two points on the same parallel. By default, the azimuth function references the points to the unit sphere and calculates the great circle azimuth.

    az1 = azimuth(10,10,10,40)
    az1 = 
    87.3360
    

    Find the rhumb line azimuth between the same two points.

    az2 = azimuth("rh",10,10,10,40)
    az2 = 
    90
    

    Create a World Geodetic System of 1984 (WGS84) reference ellipsoid with a length unit of kilometers.

    wgs84 = wgs84Ellipsoid("km");

    Calculate the azimuth between Munich and Madrid. Reference the coordinates to the ellipsoid.

    az = azimuth(48.155,11.4716,41.6427,-5.1327,wgs84)
    az = 
    247.1825
    

    Input Arguments

    collapse all

    Latitude of the start point, specified as a scalar or array.

    You can specify lat1, lon1, lat2, and lon2 using a combination of scalars and arrays, as long as the arrays are of the same size. The function expands the scalar inputs to match the size of the array inputs.

    Data Types: single | double

    Longitude of the start point, specified as a scalar or array.

    You can specify lat1, lon1, lat2, and lon2 using a combination of scalars and arrays, as long as the arrays are of the same size. The function expands the scalar inputs to match the size of the array inputs.

    Data Types: single | double

    Latitude of the end point, specified as a scalar or array.

    You can specify lat1, lon1, lat2, and lon2 using a combination of scalars and arrays, as long as the arrays are of the same size. The function expands the scalar inputs to match the size of the array inputs.

    Data Types: single | double

    Longitude of the end point, specified as a scalar or array.

    You can specify lat1, lon1, lat2, and lon2 using a combination of scalars and arrays, as long as the arrays are of the same size. The function expands the scalar inputs to match the size of the array inputs.

    Data Types: single | double

    Reference ellipsoid, specified as a referenceSphere object, a referenceEllipsoid object, an oblateSpheroid object, or a two-element vector of the form [semimajor_axis eccentricity], where semimajor_axis is the length of the semimajor axis and eccentricity is the eccentricity. The values semimajor_axis and eccentricity must be of data type double.

    The default value of [1 0] represents the unit sphere.

    Angle unit, specified as one of these options:

    • "degrees" — Degrees

    • "radians" — Radians

    Data Types: char | string

    Type of curve connecting the start point and end point, specified as one of these options:

    • "gc" — For spheres, calculate the azimuth using the starting point of the great circle path that connects the points. For ellipsoids, calculate the azimuth using the starting point of the geodesic that connects the points.

    • "rh" — Calculate the azimuth using the rhumb line that connects the points.

    For more information about rhumb lines and great circles, see Comparison of Rhumb Lines and Great Circles.

    Data Types: char | string

    Output Arguments

    collapse all

    Azimuth, returned as a scalar or an array that matches the size of the largest latitude or longitude input.

    • When units is "degrees", the azimuth is in the range in the range [0, 360) degrees.

    • When units is "radians", the azimuth is in the range [0, 2π) radians.

    This table shows the azimuths associated with cardinal and intercardinal compass directions.

    Compass DirectionAzimuth

    North

    0° or 360°

    Northeast

    45°

    East

    90°

    Southeast

    135°

    South

    180°

    Southwest

    225°

    West

    270°

    Northwest

    315°

    More About

    collapse all

    Azimuth

    An azimuth is the angle at which a smooth curve crosses a meridian, taken clockwise from north. For example, the north pole has an azimuth of 0º from every other point on the globe.

    Algorithms

    collapse all

    Azimuths over Long Geodesics

    The accuracy of geodesic azimuth calculations decreases as the distance between the points increases. Additionally, the calculations can break down when the points are nearly antipodal or close to the equator.

    When you specify a reference ellipsoid and two points that are both close to the equator and nearly antipodal, the azimuth function issues a warning and returns a value of NaN.

    Eccentricity

    Geodesic azimuths on an ellipsoid are valid only when the ellipsoid has a small eccentricity typical of Earth, such as 0.08 or less.

    Alternative Functionality

    Calculate both the distance and the azimuth between two points by using the distance function.

    Version History

    Introduced before R2006a