//converts points to WGS84 (WKID=4326) and then does math on converted points private double CalcWorldLength(MapPoint pt1, MapPoint pt2) { WebMercator web = new WebMercator(); MapPoint wgsPt1 = (MapPoint)web.ToGeographic(pt1); MapPoint wgsPt2 = (MapPoint)web.ToGeographic(pt2); double[] ppt1 = ProjectPoint(wgsPt1.X, wgsPt1.Y); double[] ppt2 = ProjectPoint(wgsPt2.X, wgsPt2.Y); double ret = Math.Round(Math.Abs(Math.Pow((Math.Pow((ppt2[0] - ppt1[0]), 2) + Math.Pow((ppt2[1] - ppt1[1]), 2)), .5))); return ret; }
geometryService.AreasAndLengthsAsync(graphicList, ESRI.ArcGIS.Client.Tasks.LinearUnit.Foot, ESRI.ArcGIS.Client.Tasks.LinearUnit.Foot,CalculationType.Geodesic);
Solved! Go to Solution.
but I found that the answer is consistently off in both area and length by a particular ratio (unit values being returned are always ~1.35x bigger than they should be).
but I found that the answer is consistently off in both area and length by a particular ratio (unit values being returned are always ~1.35x bigger than they should be).
To get accurate results, you have better to use Equal Area Projection such as WKID 54034.
Your result is likely due to the Web Mercator distorsion which is 1/cos(latitude).
That being said, the best approach is likely to use the built-in geodesic methods.
This method should return accurate results when your input in in geographical coordinates and is Superior to the Euclidian method that you tested.
Note that a negative value is normal if your polygon is oriented in a counter clock wise direction.