Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Lets say I have two sets of latitude and longitude. How do I find the distance between the two locations if I assume the earth is a perfect ellipsoid (with an eccentricity of 0.0167)?

share|improve this question

3 Answers 3

up vote 15 down vote accepted

I would recommend checking out:
Spherical: http://www.movable-type.co.uk/scripts/latlong.html
Great-Circle: http://www.movable-type.co.uk/scripts/gis-faq-5.1.html

share|improve this answer
The formulas on that page appear to ignore eccentricity. They assume the earth is a sphere and not an ellipsoid. –  Jon Bringhurst Jul 22 '10 at 19:14
Previously I always used a library that had known distances between some set lat long points then performed averaging to calculate distance of any unknown points. I will ask a few people about this. –  Wallbasher Jul 22 '10 at 19:17
Ah, the second link seems to have the right formula. Thanks! –  Jon Bringhurst Jul 22 '10 at 19:34
Thanks for your answer @Wallbasher. However, it would be best if the answers could stand on their own. It would greatly help if you would post the relevant formula with your answer as well. –  R.K. May 1 '13 at 2:02

So you know your two latitudes and longitudes, lets say

You can calculate the cartesian co-ordinates for each:

xa = (Cos(thisLat)) * (Cos(thisLong));
ya = (Cos(thisLat)) * (Sin(thisLong));
za = (Sin(thisLat));

xb = (Cos(otherLat)) * (Cos(otherLong));
yb = (Cos(otherLat)) * (Sin(otherLong));
zb = (Sin(otherLat));

And then calculate the great circle distance between the two using:

MeanRadius * Acos(xa * xb + ya * yb + za * zb);

This simplified approach allows pre-calculation of the x, y and z values, which can be stored alongside in a database for efficient "points within x miles" queries.

Of course, this assumes a perfect sphere, and the Earth isn't even a perfect elipsoid, so accuracy is only going to be to a few metres.

share|improve this answer
I was going to point out the "perfect sphere thing" also. You should be aware that this method will give you varying degrees of accuracy depending on where you are on the globe. –  TroutSlayer Jul 22 '10 at 22:49
@TrotuSlayer it's generally good enough for most applications, and there is always a trade off between speed and accuracy. If you need to be more accurate, it's time to get the trundle wheel out, or resort to assumptions the the Earth is flat for your given area, and 2D distances are sufficient. –  Rowland Shaw Jul 23 '10 at 11:34

There are a handful of useful tools on this page. One of them calculates the distance between two points. It has the option to draw the points on the map with the Great Circle showing as well as the option to draw a profile and export the data.

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.