I Tried computing the distance between two points using several different ways, and in some I got different results. I wonder what could be the reason.

First, I created a polyline and added the two points to it and used IPolyline.Length property.

After that I used IProximityOperator.ReturnDistance. I got the same result using these methods.

Then I tried using IMap.ComputeDistance and got a different result.

I got even more confused when I tried drawing the points on the map and measuring the distance between the points using the MapMeasureTool. When I measured the distance using Meters as the unit, I got the result of the first two methods (converted to Meters, of course). When I changed the tool units to Decimal Degrees (my map units), I got the result of the third method (IMap.ComputeDistance).

Am I missing something basic here?

Thanks

First, I created a polyline and added the two points to it and used IPolyline.Length property.

After that I used IProximityOperator.ReturnDistance. I got the same result using these methods.

Then I tried using IMap.ComputeDistance and got a different result.

I got even more confused when I tried drawing the points on the map and measuring the distance between the points using the MapMeasureTool. When I measured the distance using Meters as the unit, I got the result of the first two methods (converted to Meters, of course). When I changed the tool units to Decimal Degrees (my map units), I got the result of the third method (IMap.ComputeDistance).

Am I missing something basic here?

Thanks

The length reported by Ipolyline.length will be in the coordinates of the data's coordinate system. This could be meters, feet, nautical miles and even decimal degrees. The thing to remember is that is just the distance in the cartesian coordinate system stored in the database (X,Y coordinate system.) Most coordinate systems depend on a map projection that defines it. Map projections all have distortion, only equidistant projections preserve distance. How accurate is the measurement depends on the projection, how much accuracy you need depends on the application.

For high accuracy over long distances, there is a class called MeasurementToolClass part of the defensesolutions to do that. I have used it back when it was part of military analyst but now it is core functionality.