You should be able to use the Lat, Lon coordinates to calculate a distance without an API. A Bing search returns a mathematical option for conversion from degrees to km, for example. https://www.bing.com/search?q=convert+degree+longitude+to+km
Alternative to Spacial Great Circle Distance API
Keerthi Pradhani
20
Reputation points Microsoft Employee
I am currently attempting to utilize the Spacial Great Circle Distance API to calculate the distance between two points. However, I have noticed that this API has been deprecated. Could you please advise if there is an alternative solution available?
Accepted answer
1 additional answer
Sort by: Most helpful
-
rbrundritt 19,306 Reputation points Microsoft Employee
2025-02-03T20:06:20.4766667+00:00 As IoTGirl mentioned, straight line distance calculations are fair easy to do in code. In fact they are generally pretty fast too. The great circle distance API you referenced was primarily for use in low powered systems like IoT devices.
There are a couple of common formula's used for this calculation.
- Haversine formula - The most commonly used formula I have seen used for distance between points calculations and based on a spherical globe. You can find versions of this for nearly every programming language here: https://rosettacode.org/wiki/Haversine_formula
- Vincenty Formula - A more advanced formula based on an ellipsoid (squashed sphere) that should be slightly more accurate but is slower than haversine. Generally, the accuracy difference with haversine isn't need for most scenarios (I believe it's around a max of 0.5%). https://www.movable-type.co.uk/scripts/latlong-vincenty.html
- Law of Cosines - This is a simple and fast calculation; however this becomes less accurate over longer distances (anything more than a few 100km) https://www.themathdoctors.org/distances-on-earth-1-the-cosine-formula/