views:

681

answers:

2

I've managed to get two functions working to calculate distances between two point on a google map. One that I gleaned(stole) from various places on the web and the other using the GLatLng.distanceFrom method in the Google Maps API.

The reason I'm using two functions is because I noticed something odd about the results I was getting form Google, for example, the distance between Lands End and John O Groats in the UK is returned as follows

  • My Function: 985km
  • Google: 986km
  • Wikipedia: 970km

The 15/16km difference from the Wikipedia result is because Google return a location result about 15 km away from the actual John O Groats. So that's about right.

So then I tested the distance between London and Milan and got

  • My Function: 1232km
  • Google: 1234km
  • Wolfram Alpha: 958.5km

So someone is more than 250km out. Then I tried London to New York

  • My Function: 8244km
  • Google: 8254km
  • Wolfram Alpha: 5581km

Generally, the distance between London and New York is thought to be around 5560km. But now both my function and the Google function appear to be way off the mark.

The function I'm using can be found here. My Apologies to the author for not linking to the original site, but the layout is really confusing. I'm using the distHaversine function.

I must admit, the maths is way beyond my comfort level, but I get the gist, and as I understand it, Google uses the Haversine method too. I also understand that it can be off by about 0.3%, but that wouldn't account for the differences I'm seeing. And I'm further confused by the fact that it's sometimes right on, and sometimes way off the commonly stated distances between places. It appears the greater the distance, the more off it is.

So who's wrong. Google and the function I'm using, or everyone else?

+1  A: 

Unless I'm misunderstanding this:

Could the discrepancy emanate from the fact that Google Maps calculates distance that you drive and not 'as the crow flies'?

Tyler
See the comment of gargantaun at the origininal question. Problem is solved, but nobody gave an 'answer'
Peter Smit
+2  A: 

Google Maps doesn't calculate the shortest straight distance -- it goes by roads and (air, water, ?)

Sam