ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / GeodeticDistanceAndAzimuth Method / GeodeticDistanceAndAzimuth(MapPoint,MapPoint,GeodeticCurveType,LinearUnit,Double,Double) Method
The first input point. Cannot be null.
The second input point. Cannot be null.
The geodetic curve type.
The units of the output distance. If null, then the distance is in meters.
The azimuth from point1 to point2 in radians.
The azimuth from point2 to point1 in radians.
Example

In This Topic
    GeodeticDistanceAndAzimuth(MapPoint,MapPoint,GeodeticCurveType,LinearUnit,Double,Double) Method
    In This Topic
    Calculates distance and azimuth on the spheroid between two points using the given geodetic curve type.
    Syntax
    Public Overloads Function GeodeticDistanceAndAzimuth( _
       ByVal point1 As MapPoint, _
       ByVal point2 As MapPoint, _
       ByVal curveType As GeodeticCurveType, _
       ByVal distanceUnit As LinearUnit, _
       ByRef azimuth12 As Double, _
       ByRef azimuth21 As Double _
    ) As Double

    Parameters

    point1
    The first input point. Cannot be null.
    point2
    The second input point. Cannot be null.
    curveType
    The geodetic curve type.
    distanceUnit
    The units of the output distance. If null, then the distance is in meters.
    azimuth12
    The azimuth from point1 to point2 in radians.
    azimuth21
    The azimuth from point2 to point1 in radians.

    Return Value

    Geodetic distance between the two points in distanceUnit. If distanceUnit is null, then the geodetic distance is in meters.
    Exceptions
    ExceptionDescription
    One or both of the input points are null, or both of the geometry spatial references are null.
    The spattial references of point1 and point2 are not equal.
    Spatial reference of point1 or point2 is an image coordinate system.
    Remarks
    If point1 or point2 are empty, then azimuth12 = 0, azimuth21 = 0 and the returned geodetic distance is NaN.

    If one of the spatial references is null and the other is not null, then the non-null spatial reference is used. If both spatial references are null, then an exception is thrown. If both spatial references are not null but not equal, then an exception is thrown.

    Example
    Calculate geodetic distance, azimuth between two points
    SpatialReference sr = SpatialReferences.WGS84;
    
    MapPoint p1 = MapPointBuilderEx.CreateMapPoint(111, 55, sr);
    MapPoint p2 = MapPointBuilderEx.CreateMapPoint(95.5845, 64.2285, sr);
    
    double distance, az12, az21;
    
    distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p1, p2, GeodeticCurveType.Geodesic, out az12, out az21);
    // distance - 1339728.0303777338
    // az12 - 326.235780421405
    // az21 - 132.87425637913955
    
    distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p1, p2, GeodeticCurveType.Loxodrome, out az12, out az21);
    // distance - 1342745.9687172563
    // az12 - 319.966400332104
    // az21- 139.96640033210397
    
    distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p1, p2, GeodeticCurveType.GreatElliptic, out az12, out az21);
    // distance - 1339728.038837946
    // az12 - 326.22479262335418
    // az21 - 132.88558894347742
    
    
    
    MapPoint p3 = MapPointBuilderEx.CreateMapPoint(0, 0, sr);
    MapPoint p4 = MapPointBuilderEx.CreateMapPoint(1, 0, sr);
    
    distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p3, p4, GeodeticCurveType.Geodesic, out az12, out az21);
    // distance - 111319.49079327342
    // az12 - 90
    // az21 - 270
    
    distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p3, p4, GeodeticCurveType.Geodesic, LinearUnit.Miles, out az12, out az21);
    // distance - 69.1707247134693
    // az12 - 90
    // az21 - 270
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also