Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GeoCoordinate.GetDistanceTo using wrong radius for Earth?

I decompiled System.Device.Location.GeoCoordinate.GetDistanceTo(...), and found it uses the Haversine formula, which should specify the Earth's radius as one of the steps of calculation.

The radius specified in the decompiled code is 6376500.0 (meters).

In MSDN, the documentation for GetDistanceTo has a remark:

The Haversine formula accounts for the curvature of the earth, but assumes a spherical earth rather than an ellipsoid.

Wikipedia states that

Several different ways of modeling the Earth as a sphere each yield a mean radius of 6,371 kilometers

Also everywhere I search, I find cannot find anyone very few specifying the radius as 6,376.5 km.

So, even though they're pretty close, GetDistanceTo uses 6,376.5 km, but the widely accepted radius is 6,371 km. Why the difference? Did the creators of GetDistanceTo figure out a better way to approximate the radius of the Earth?

like image 951
David S. Avatar asked Feb 25 '26 09:02

David S.


1 Answers

Unless my maths are out, this could lead to a difference of up to 34 km.

Sounds a lot, but only an additional 0.17% error.

Perhaps you could only use/display the results to 2 significant places then it won't really matter.

like image 173
weston Avatar answered Feb 27 '26 23:02

weston



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!