Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm coding a Web App whereby users can choose their city (start) and a destination city, and find out the approximate distance between both cities, using Latitude and Longitude of both cities to calcultate. Then i thought that since this will be done using the concept of a Straight Line on a sphere, it means that i'll be getting a result of a straight line which is the shortest, but in reality (driving route especially), will have hills, curves, turns. It might be practically impossible to have an accurate distance, but how can i make the app more accurate that just a straight line distance.

I'll be most delighted by you opinions, suggestions, answers and comments. Thanks in advance.

share|improve this question
up vote 2 down vote accepted

If you want to factor-in more accurate driving distances, I recommend pitching-out to a free service already providing these sort of metrics like Google's or MapQuest's.

Google's seems to rightly-check for crazy inputs. I tried getting driving directions from Boston, MA, to Malé, Maldives, and the service replied it could not connect the two; it's possible the API returns some fail codes but I can't say for certain.

So in your map, you could start by first calling the free driving directions service. This might require summing the different segment lengths to get the full distance. But, if the driving directions service returned a fail code, you could do a straight line geodedic measurement and provide the user a clue that the value is approximated. ..Here's a thought, you could wire-up more than one service and either take the average, or the non-failed if that were the case.

You're using Long/Lat (geodetic) coordinates, so I assume you're worldwide and not localized to one or two countries. On the whole, I think you'll find this to be true: As you map a smaller area, your potential to achieve great accuracy increases, but as you map large areas, you gradually trade greater accuracy for the larger area. Of course, this assumes you have access to the same modest data as the rest of us. If you're sitting on the world's best dataset, maybe you can beat the rule.

share|improve this answer

I'm in the same situation. I believe you want to use the Geography type instead of the Geometry type.

I believe the difference is that geography types are spherical in nature vs straight line as in geometry types.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.