ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / Distance3D Method
The first geometry.
The second geometry.
Example

In This Topic
    Distance3D Method (IGeometryEngine)
    In This Topic
    Measures the 3-dimensional planar distance between two geometries.
    Syntax
    Function Distance3D( _
       ByVal geometry1 As Geometry, _
       ByVal geometry2 As Geometry _
    ) As Double

    Parameters

    geometry1
    The first geometry.
    geometry2
    The second geometry.

    Return Value

    The distance between the two input geometries in the same unit as the spatial reference of the input geometries. If either of the input geometries is empty, then NaN is returned.
    Exceptions
    ExceptionDescription
    Either geometry1 or geometry2 or both are null.
    The method is not implemented for GeometryBag.
    Incompatible spatial references between the input geometries.
    Either geometry1 or geometry2 is not Z-Aware.
    Remarks
    Returns the minimum distance between two Z-Aware geometries in 3D space. If the geometries intersect, the minimum distance is 0. Only returns the distance, not the nearest points.
    Example
    Determine 3D distance between two Geometries
    // between points 
    MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 1, 1);
    MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2, 2, 2);
    MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(10, 2, 1);
    
    // pt1 to pt2
    double d = GeometryEngine.Instance.Distance3D(pt1, pt2);        // d = Math.Sqrt(3)
    
    // pt1 to pt3
    d = GeometryEngine.Instance.Distance3D(pt1, pt3);        // d = Math.Sqrt(82)
    
    // pt2 to pt3
    d = GeometryEngine.Instance.Distance3D(pt2, pt3);        // d = Math.Sqrt(65)
    
    // intersecting lines
    
    List<MapPoint> list = new List<MapPoint>();
    list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 1.0));
    list.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0, 1.0));
    list.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0, 1.0));
    
    Polyline line1 = PolylineBuilderEx.CreatePolyline(list);
    
    List<MapPoint> list2 = new List<MapPoint>();
    list2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 1.0));
    list2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 1.0));
    list2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0, 1.0));
    
    Polyline line2 = PolylineBuilderEx.CreatePolyline(list2);
    
    bool intersects = GeometryEngine.Instance.Intersects(line1, line2);    // intersects = true
    d = GeometryEngine.Instance.Distance3D(line1, line2);                  // d = 0   (distance is 0 when geomtries intersect)
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also