Wednesday, March 24, 2010

Calculating Distance with Google Maps

The Distance Between Two Points

Now we all know the shortest path between two points is a straight line. Unfortunately, unless you believe the Flat Earth Society, any journey between two points on Earth usually requires you to make a bit of an arc in your journey. Therefore, when you measure a distance on a two dimensional map, your calculations are likely to be wrong, unless you allow for the curvature of the Earth.

Luckily Chris Veness has created a JavaScript that uses the 'Haversine' formula to calculate great-circle distances between two points and view the result on a Google Map. The script can do a few other things as well, such as work out the destination point given a distance and a bearing from a start point, work out a rhumb line and even show the intersection of two paths given the start points and bearings.

To top it all off the script is available for free under a Creative Commons license.

_____________
Post a Comment