Show / Hide Table of Contents

Method NearestCoordinate

NearestCoordinate(Geometry, MapPoint)

Determines the nearest point in the input geometry to the input point using a simple planar measurement.

Declaration
public static ProximityResult? NearestCoordinate(this Geometry geometry, MapPoint point)
Parameters
Type Name Description
Geometry geometry

The geometry in which the nearest coordinate to a specified point is to be found.

MapPoint point

The point which to find the nearest coordinate to.

Returns
Type Description
ProximityResult

A ProximityResult containing the results of the operation. This is null if the input geometry is empty. Distance is zero if the point lies inside an input polygon, polyline, or envelope.

Remarks

If the specified geometry is a polyline or polygon the nearest coordinate is the closest point in the line segment that comprises geometry; it may not necessarily be the closest vertex of line segment. If you want to obtain the closest vertex in the polyline or polygon use the NearestVertex(Geometry, MapPoint) method instead.

If the specified geometry is an envelope, the geometry will first be converted to a Polygon to perform the calculation of the nearest coordinate. The final PartIndex will always be invalid for an envelope.

Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, NearestCoordinateGeodetic(Geometry, MapPoint, double, LinearUnit?).

Supports true curves.

Exceptions
Type Condition
ArgumentException

Indicates that geometry and point do not have equivalent spatial references.

See Also
NearestVertex(Geometry, MapPoint)
NearestCoordinateGeodetic(Geometry, MapPoint, double, LinearUnit)

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.8
.NET100.13 - 300.0
.NET Windows100.13 - 300.0
.NET Android200.0 - 300.0
.NET iOS200.0 - 300.0
.NET Framework100.0 - 200.8
Xamarin.Android100.0 - 100.15
Xamarin.iOS100.0 - 100.15
UWP100.0 - 200.8
Relevant samples
Nearest vertex: Find the closest vertex and coordinate of a geometry to a point.
In this article
Provide feedback
Back to top Copyright © 2025 Esri.