Finding distances using latitude and longitude


I posted a page this evening that lets you calculate the distance between two locations using their latitudes and longitudes. I’ve had to do this calculation once in a while and thought I’d make it available online for anyone else who needed to do the same. There is one page providing an online calculator and another page giving the formula used to calculate the distances and its derivation.

This project was prompted by a friend asking me how far my home is from Galveston where the hurricane is supposed to make landfall this weekend. Since we live northwest of Houston, we’re pretty far inland.

Related posts

3 thoughts on “Finding distances using latitude and longitude

  1. A useful calculation. Note that for distances below about 10 miles, you should use an expansion of arccos around 1, since the arccos loses precison. At that distance, though, you might as well just use pythagoras and delta_long * cos(avg_lat).

  2. So what is the best way to do the reverse? Given a starting lat/lon, compass heading and distance, what is the lat/lon where you end? What would the best short distance approximation be and what would its limits be? It would seem that a more complex model than spherical would have to be used going this direction to be useful.

  3. Sam, you can easily calculate that using a spherical triangle with the North pole, your starting point, and the ending point. Then you have two sides and the included angle, from which you can calculate the rest.

    The short distance approximation is always flat-plane, since the relative curvature depends on how far you travel.

    The only corrections needed to a spherical model are the deviations of the Earth from a sphere. Namely, changing radius with latitude, and the deviation if your starting and ending points are not at the same elevation.

Comments are closed.