ArcGIS Pro 2.7 API Reference Guide
NearestPoint3D Method (GeometryEngine)
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class : NearestPoint3D Method
The geometry.
The point to which the returned point will be nearest.
Finds the nearest point, in 3D space, on a z-aware geometry to a specified point.
Syntax
public ProximityResult NearestPoint3D( 
   Geometry geometry,
   MapPoint point
)
Public Function NearestPoint3D( _
   ByVal geometry As Geometry, _
   ByVal point As MapPoint _
) As ProximityResult

Parameters

geometry
The geometry.
point
The point to which the returned point will be nearest.

Return Value

ProximityResult.

If the input geometry is a Point, then ProximityResult.PointIndex = 0, ProximityResult.PartIndex = 0, and ProximityResult.SegmentIndex is null.

If the input geometry is a Multipoint, ProximityResult.PointIndex is the index of the nearest point in the Multipoint, ProximityResult.PartIndex = ProximityResult.PointIndex, and ProximityResult.SegmentIndex is null.

Otherwise, ProximityResult.PointIndex is null and ProximityResult.SegmentIndex is the segment which contains the nearest point. The segment index is relative to the ProximityResult.PartIndex. For example, if the segment index = 0 and the part index = 2, then the segment containing the nearest point is segment 0 of part 2. In other words, the segment is the first segment of the third part.

Proximity.RightSide is irrelevant for 3D operations and is always set to false.

Exceptions
ExceptionDescription
Geometry is null or empty.
The method is not implemented for GeometryBag.
The geometry is not Z-Aware.
This function is not implemented for envelopes.
Cannot do 3D operations on curve segments.
Remarks
The nearest point does not have to be a vertex of the input geometry. It can be any point contained in the geometry.

GeometryEngine NearestPoint3D

Example
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1);

//
// test pt1 to pt2
//
ProximityResult result = GeometryEngine.Instance.NearestPoint3D(pt1, pt2);
// result.Point = 1,1,1
// result.Distance = Math.Sqrt(3)
// result.SegmentIndex = null
// result.PartIndex = 0
// result.PointIndex = 0
// result.RightSide = false

// 
// multipoint built from pt1, pt2.   should be closer to pt2
// 
Multipoint multipoint = MultipointBuilder.CreateMultipoint(new List<MapPoint>() { pt1, pt2 });
result = GeometryEngine.Instance.NearestPoint3D(multipoint, pt3);
// result.Point = 2, 2, 2
// result.Distance = Math.Sqrt(65)
// result.SegmentIndex = null
// result.PartIndex = 1
// result.PointIndex = 1
// result.RightSide = false
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members