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)?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI 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
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.
There are a handful of useful tools on the GPS Visualizer's coordinate calculators & distance tools 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.