ArcGIS Pro 2.9 API Reference Guide
NearestVertex Method (GeometryEngine)
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class : NearestVertex Method
The geometry.
The point to which the returned vertex will be nearest.
Finds the nearest vertex in the geometry to a specified point.
Syntax
public ProximityResult NearestVertex( 
   Geometry geometry,
   MapPoint point
)
Public Function NearestVertex( _
   ByVal geometry As Geometry, _
   ByVal point As MapPoint _
) As ProximityResult

Parameters

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

Return Value

ProximityResult.

ProximityResult.PointIndex is the index of the nearest vertex.

ProximityResult.SegmentIndex is null.

ProximityResult.PartIndex is the index of the part containing the nearesst vertex.

Proximity.RightSide = false.

Exceptions
ExceptionDescription
Either geometry or point or both are null or empty.
The method is not implemented for GeometryBag.
Example
SpatialReference sr = SpatialReferences.WGS84;
MapPoint pt = MapPointBuilder.CreateMapPoint(5, 5, sr);

List<Coordinate2D> coords = new List<Coordinate2D>()
{
  new Coordinate2D(10, 1),
  new Coordinate2D(10, -4),
  new Coordinate2D(0, -4),
  new Coordinate2D(0, 1),
  new Coordinate2D(10, 1)
};

Polygon polygon = PolygonBuilder.CreatePolygon(coords);

// find the nearest point in the polygon geomtry to the pt
ProximityResult result = GeometryEngine.Instance.NearestPoint(polygon, pt);
// result.Point = 5, 1
// result.SegmentIndex = 3
// result.PartIndex = 0
// result.PointIndex = null
//result.Distance = 4
//result.RightSide = false

// find the nearest vertex in the polgyon geometry to the pt
result = GeometryEngine.Instance.NearestVertex(polygon, pt);
// result.Point = 10, 1
// result.PointIndex = 0
// result.SegmentIndex = null
// result.PartIndex = 0
// result.Distance = Math.Sqrt(41)
// result.RightSide = false
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members