Measures the simple Euclidean distance between two geometries. This is a planar measurement using 2D Cartesian mathematics to calculate the distance in the same coordinate space as the inputs. Use DistanceGeodetic(MapPoint, MapPoint, LinearUnit, AngularUnit, GeodeticCurveType) for geodetic measurement.
public static double Distance(Geometry geometry1, Geometry geometry2)
The first geometry.
The second geometry.
The distance between the two input geometries in the same unit as the spatial reference of the input geometries.
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, DistanceGeodetic(MapPoint, MapPoint, LinearUnit, AngularUnit, GeodeticCurveType). See the document Spatial References for more information about spatial references.
This distance calculation is based upon the SpatialReference of the input geometries. Although some projections are better than others for preserving distance, it will always be distorted in some areas of the map. Distortion may be negligible for large scale maps (small areas) that use a suitable map projection.
Platforms and versions
|.NET Standard 2.0||100.3 - 100.14|
|.NET 6.0||100.13 - 100.14|
|.NET 6.0 Windows||100.13 - 100.14|
|.NET Framework||100.0 - 100.14|
|.NET 5||100.10 - 100.12|
|.NET Core 3.1||100.7 - 100.12|
|Xamarin.Android||100.0 - 100.14|
|Xamarin.iOS||100.0 - 100.14|
|UWP||100.0 - 100.14|