Distance Calculation#

Any point on the earth’s surface can be located by its latitude and longitude coordinates. Latitude is the angle above or below the equator in degrees. The equator is zero degrees, the North pole is North 90 degrees latitude, and the South pole is South 90 degrees latitude. The continental United States falls between 25 and 50 degrees North.

Longitude is the angle East or West of the Greenwich meridian. The continental United States is between 70 and 125 degrees West.

Approximate Solutions#

One degree of latitude is equal to 69.1 miles. One degree of longitude is equal to 69.1 miles at the equator. North or South of the equator, 1 degree of longitude is a smaller distance. It’s reduced by the cosine of the latitude. Dividing the latitude number by 57.3 converts it to radians.

\[DistanceLat = 69.1\, (Lat_2 - Lat_1)\]
\[\begin{split}DistanceLong = 69.1\, (Long_2- Long_1)\, cos\, (\frac{Lat_1}{57.3})\\\end{split}\]
\[Distance = \sqrt{DistanceLat^2 + DistanceLong^2}\]

If you don’t want to use the COS function, then a good approximate solution is:

\[DistanceLat = 69.1\, (Lat_2 - Lat_1)\]
\[DistanceLong = 53\, (Long_2- Long_1)\]
\[Distance = \sqrt{DistanceLat^2 + DistanceLong^2}\]

Exact Solution#

To calculate the exact distance between points requires spherical geometry.

The basic formula is:

\[D = 3959\, cos^{-1}\, (sin\, (Lat_1)\, sin(Lat_2)\, + cos\, (Lat_1)\, cos\, (Lat_2)\, cos\, (Long_2 - Long_1))\]

The above formula has one major problem: most computer languages do not support the arccosine function. Therefore a different form is necessary, one that uses the arctangent function that most languages embrace.

\[\begin{split}D = 3959\, tan^{-1}\, (\frac{\sqrt{1-A^2}}{A})\\\end{split}\]

where A is equal to:

\[A = sin\, (Lat_1)\, sin\, (Lat_2) + cos\, (Lat_1)\, cos\, (Lat_2)\, cos\, (Long_2-Long_1)\]

Most computer languages compute the sine and cosine function with the angle given in radians. To convert degrees to radians, divide degrees by the constant:


In BASIC this would be programmed as follows:

\[C = 57.3\]
\[\begin{split}A = sin\, ({\frac{Lat_1}{C})\\}\, sin\, ({\frac{Lat_2}{C})\\} + cos\, ({\frac{Lat_1}{C}\\})\, cos\, ({\frac{Lat_2}{C}\\})\, cos\, ({\frac{Long_2}{C}\\}-{\frac{Long_1}{C}\\})\end{split}\]
\[\begin{split}D = 3959\, tan^{-1}\, (\frac{\sqrt{1-A^2}}{A})\\\end{split}\]


D = distance in statue miles from the first to the second point.

C = degrees to radians constant 57.3.

Lat1 = latitude of the first point in degrees.

Long1 = longitude of the first point in degrees.

Lat2 = latitude of the second point in degrees.

Long2 = longitude of the second point in degrees.

NOTE: Dividing the latitude number by 57.3 converts it to radians.

Since all ZIP code points in the United States are North latitude and West longitude, there is no need to check the sines (positive and negative) of the latitudes and longitudes.

Some programming languages, such as dBASE II/III, do not have the functions of the sine, cosine and arctangent. Also, the formulas given are time-consuming to calculate. A simpler but less accurate method is given here:

\[D = 69.1\, \sqrt{(Lat_2-Lat_1)^{2} + 0.6\, (Long_2 - Long_1)^{2}}\]

Although this formula is not as accurate as the first great circle method, it will give good results for most applications. In basic, it is written as follows:

\[D = 69.1\, \sqrt{(Lat_2-Lat_1)^{2} + .6\, (Long_2 - Long_1)^{2}}\]

In dBASE III, it is written as follows:

\[D = 69.1\, \sqrt{(Lat_2-Lat_1)^{2} + 0.6\, (Long_2 - Long_1)^{2}}\]

To make using the database easier, the latitudes and longitudes are given in the decimal format instead of the degree, minute and second format. The latter would require the additional steps of converting seconds to fractions of a minute and then minutes to a fraction of a degree.

Bearing Formula#

The bearing is the direction from the first point to the second point. It is expressed as an angle from North in degrees. Due North is a bearing of zero degrees, East is a bearing of 90 degrees, South is 180, and west is 270.

The bearing from the first point to the second is calculated with:

\[B = tan^{-1}\, (\frac{sin(Lat_1)\, sin(Long_2 - Long_1)}{sin(Lat_2)\, cos(Lat_1) - cos(Lat_2)\, sin(Lat_1)\, cos(Long_2 - Long_1)})\]

Since the ARCTAN function gives the angle in radians, it is necessary to convert B to degrees by multiplying by


To use this equation requires some special considerations. This example assumes that Lat1, Lat2, Long1, Long2 have been converted to radians.

Use the following steps:

\[N = sin\, (Lat_1)\, sin\, (Long_1 - Long_2)\]
\[D = sin\, (Lat_2)\, cos\, (Lat_1)\, – \, cos\, (Lat_2)\, sin\, (Lat_1)\, cos\, (Long_1 - Long_2)\]
\[\begin{split}B = 57.3\, tan^{-1}\, ({\frac{N}{D}\\})\end{split}\]

If (D > 0) then (B = 360 + B)

If (D < 0) then (B = 180 + B)

If (B < 0) then (B = 360 + B)


N is the Numerator.

D is the Denominator.

B is the Bearing.

Release Schedule#

Release Date Schedule