1

I am calculating the distance between two points given by latlng. However, Google Maps (i.e., web mercator projection) gives me a longer distance than Haversine formula.

Which is the most accurate measure? I can read in some answer that Haversine formula gives it.

So... Is Google Map lying when telling me distance in meters. e.g., in this webpage? http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

Edit:

Example: In a small area around (37,0), if I calculate area (width,height), haversine results in (7750m*7753m) while Google results in (9784m*9784m).

pedromateo
  • 161
  • 1
  • 7
  • 1
    How large are the differences you experience? Since the Haversine uses a spherical earth model, it will err slightly, depending on the configuration of the endpoints: see http://gis.stackexchange.com/questions/25494 for an analysis. Please give us a link to any answer that claims the Haversine formula is the "most accurate measure" so that we can help correct it. – whuber May 19 '15 at 12:04
  • I edited the question to give an example. Sorry, I can not provide real coordinates. Hope it helps. – pedromateo May 20 '15 at 09:14
  • Clearly those "Google results" are using the Mercator-projected coordinates, which will inflate distances at 37 degrees latitude by 25%. But Google Maps provides various ways of computing distances and some of them--such as its measurement tool--appear to be accurate. Exactly how are you using Google Maps to obtain these distances? – whuber May 20 '15 at 13:22
  • Only slightly related, but why are you using Haversine and not Vincenty? – Mikkel Lydholm Rasmussen May 20 '15 at 14:16
  • @Mikkel Presumably because Google uses a spherical earth model for its "Web Mercator" projection. Even so, your question is pertinent because this thread is wondering about "most accurate measure" of distances, and surely a calculation using an ellipsoidal model will be more accurate than using a spherical model: see http://gis.stackexchange.com/questions/25494. – whuber May 20 '15 at 14:36
  • @whuber It seems strange to validate something (google) with something fictional (haversine). As you have noted, Haversine is based on spheres and not spheroids. The Web Mercator (EPSG:3857) is based on WGS84 and thus a spheroids. – Mikkel Lydholm Rasmussen May 20 '15 at 14:53
  • @Mikkel We need to take some care concerning what "based on" means in Google's case, because it actually is a corrupted version of the appropriate procedures. As Wikipedia puts it, "the Web Mercator uses the spherical formulas at all scales whereas large-scale Mercator maps normally use the ellipsoidal form of the projection." It would therefore be reasonable to try to check Google's reported distances by applying spherical formulas--that is, the Haversine or its equivalent. Given the large discrepancy reported in the edit, though, that's a moot point now. – whuber May 20 '15 at 14:57
  • @whuber very true about the way the Web Mercator functions relating to spheres and spheroids, but I appear to have misunderstood the question in total. I expected it to be focused on calculating the distance between two points as correctly as possible and then compare that result to the result provided by Google, rather than replicating the problematic issues relating to Web Mercator. – Mikkel Lydholm Rasmussen May 20 '15 at 15:06
  • @Mikkel I think that's still a good interpretation. However, the edit shows that a much more egregious issue has to be dealt with first. The discrepancies between an ellipsoidal and spherical calculation will not exceed one part in 300, whereas the reported discrepancy is a 25% difference. Although this apparently is a result of using a Mercator projection, it's not evident how the OP obtained it, so we're waiting for clarification. – whuber May 20 '15 at 15:24
  • @MikkelLydholmRasmussen and whuber, I am using Haversine because I am working with Leaflet, and Haversine is the default formula in Leaflet to measure distances between two latlng points. Anyway, our client uses Robbins & Clarke, so we have to adapt to them. Results with Robbins & Clarke formulae are quite similar to Haversine. What is your opinion about this formula? – pedromateo May 21 '15 at 07:18
  • @pedromateo I am uncertain as to how you ended up with the big differences posted in the original, but I do expect that it is through unintended use of some information from Google. As far as I know, when measuring distances in Google Maps it is based on a great-circle distance calculation that is comparable to haversine. It should definitely not result in 2000m errors in 7000 to 9000 meters. Anyway, if the client wants Robbins & Clarke, that is what should be used, unless you can provide them with a good enough reason to go beyond that into something better, like Vincenty. – Mikkel Lydholm Rasmussen May 21 '15 at 08:47
  • @MikkelLydholmRasmussen the metres given in this webpage http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ give me that 25% error whuber mentioned before – pedromateo May 21 '15 at 12:38
  • @pedromateo have you tried measuring directly in Google Maps to see if that gives you a different number? That tool you link appear to be focused on creating image-tiles, not spatial measurements. It could be possible that the 9784 by 9784 is not the area measured, but the size of the tiles at that zoom level. I'm just guessing, as I haven't had time to look into the code available there. – Mikkel Lydholm Rasmussen May 21 '15 at 12:52
  • @MikkelLydholmRasmussen the size of the area at zoom 14 is 4x4 tiles, 1024x1024 pixels. Tiles are always 256x256 pixels in that webpage. If you click in a tile you can see, among other measures, meters in spherical mercator projection. These meters are those that give a 25% error in an area about 8x8 km – pedromateo May 22 '15 at 07:12
  • @pedromateo I don't think that it should be utilized to measure areas and lengths, but I am not certain. – Mikkel Lydholm Rasmussen May 26 '15 at 11:15

0 Answers0