Town Hunter    Home   Site Map   Links   Contact Us  
Powered by TriVee Inc. 
City Data City Search Calculators Support Directory About
Page Help 
 
Finding the milage between cities is, of course, simply an exercise in spherical geometry, at least once the latitude and longitude of the two cities are known. Creating a milage calculator therefore is just a matter of exercising the following algorithm since the latitude and longitude of all the cities in the USA is publicly available information. A milage zip calculator can be derived from that as well.
1. Taking the easiest case first, imagine that you have two points which are on exactly the same meridian of longitude. In that case, the only relevant data is the latitude of each of the two cities. Each degree of latitude corresponds to a constant distance, irrespective of where on the Earth's surface you are. If you know the Earth's radius (EarthR), which is approximately 6400 km, or 4000 miles, then each degree of latitude corresponds to 2*Pi*EarthR / 360, since the circumference of a circle is 2*Pi*Radius, and there are exactly 360 degrees in a circle. Thus, in miles, each degree of latitude is approximately 70 miles. In kilometers, each degree of latitude is approximately 1.6 kilometers/mile * 70 miles = 112 kilometers.
2. Next, let us move on to the next simplest case, that of two cities on the same latitude, but different longitudes. The milage between the cities, in this case, depends on their latitude, since the distance between meridians of longitude shrinks as the latitude moves further away from the equator. At any given latitude, the circle which that latitude inscribes around the Earth has a radius equal to cos(Latitude) * EarthR, where cos is the cosine. Thus, since there are still 360 equal divisions of longitude around this smaller circle, each degree of longitude corresponds to 2*Pi*cos(Latitude)*EarthR / 360. For example, at 60 degrees latitude, each degree of longitude corresponds to approximately 35 miles, or 56 kilometers. At 45 degrees latitude, each degree of longitude is approximately 50 miles or 80 kilometers.
3. The final case is when both the longitude and latitude of the cities are different. The full formulas for these calculations are quite complex, but for reasonably small (within a single state, for example) distances, some good approximations can be made. In this case, we will calculate the difference in longitudinal distance, x, by taking the average latitude, and calculating the distance as in case 2 above. We then calculate the latitudinal distance, y, as in case 1, and approximate the surface of the sphere by a plane, thus using the simple Pythagorean theorem to compute the overall distance as the square root of (x^2 + y^2). This will give us the overall milage between the two cities. As you can see, finding the mileage between cities is fairly straightforward, if you have the right data.