ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / GeodesicDistance Method / GeodesicDistance(Geometry,Geometry,LinearUnit) Method
The first geometry. Cannot be null and its spatial reference cannot be null.
The second geometry. Cannot be null and its spatial reference cannot be null.
The units of the output distance. If null, then the distance is in meters.
Example

In This Topic
    GeodesicDistance(Geometry,Geometry,LinearUnit) Method
    In This Topic
    Calculates the geodesic distance between two geometries.
    Syntax
    Overloads Function GeodesicDistance( _
       ByVal geometry1 As Geometry, _
       ByVal geometry2 As Geometry, _
       ByVal distanceUnit As LinearUnit _
    ) As Double

    Parameters

    geometry1
    The first geometry. Cannot be null and its spatial reference cannot be null.
    geometry2
    The second geometry. Cannot be null and its spatial reference cannot be null.
    distanceUnit
    The units of the output distance. If null, then the distance is in meters.

    Return Value

    The geodesic distance between the two geometries in distanceUnit. If distanceUnit is null, then the geodesic distance is returned in meters.

    If either of the input geometries is empty, then NaN is returned.

    Exceptions
    ExceptionDescription
    Either geometry1 or geometry2 or both are null. Or the spatial reference of either geometry is null.
    The method is not implemented for GeometryBag or Multipatch.
    Incompatible spatial references between the input geometries.
    Spatial reference of geometry1or geometry2is an image coordinate system.
    Remarks
    Geodesic distance is the shortest distance between two points on the surface of the Earth.
    Example
    Determine geodesic distance between two Geometries
    var point1 = MapPointBuilderEx.CreateMapPoint(-170, 45, SpatialReferences.WGS84);
    var point2 = MapPointBuilderEx.CreateMapPoint(170, 45, SpatialReferences.WGS84);
    
    var distances_meters = GeometryEngine.Instance.GeodesicDistance(point1, point2);
    // distance is approximately 1572912.2066940258 in meters
    
    var distance_feet = GeometryEngine.Instance.GeodesicDistance(point1, point2, LinearUnit.Feet);
    // distance is approximately  5160473.11904786 in feet
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also