Other#

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:

\[\begin{split}57.3\,({\frac{180}{\pi}\\})\end{split}\]

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}\]

Where:

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

\[\begin{split}57.3\,({\frac{180}{\pi}\\})\end{split}\]

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)

Where:

N is the Numerator.

D is the Denominator.

B is the Bearing.

State Abbreviations and Codes#

Abbreviation

Code

State

AL

01

Alabama

AK

02

Alaska

AZ

04

Arizona

AR

05

Arkansas

CA

06

California

CO

08

Colorado

CT

09

Connecticut

DE

10

Delaware

DC

11

District Columbia

FL

12

Florida

GA

13

Georgia

HI

15

Hawaii

ID

16

Idaho

IL

17

Illinois

IN

18

Indiana

IA

19

Iowa

KS

20

Kansas

KY

21

Kentucky

LA

22

Louisiana

ME

23

Maine

MD

24

Maryland

MA

25

Massachusetts

MI

26

Michigan

MN

27

Minnesota

MS

28

Mississippi

MO

29

Missouri

MT

30

Montana

NE

31

Nebraska

NV

32

Nevada

NH

33

New Hampshire

NJ

34

New Jersey

NM

35

New Mexico

NY

36

New York

NC

37

North Carolina

ND

38

North Dakota

OH

39

Ohio

OK

40

Oklahoma

OR

41

Oregon

PA

42

Pennsylvania

RI

44

Rhode Island

SC

45

South Carolina

SD

46

South Dakota

TN

47

Tennessee

TX

48

Texas

UT

49

Utah

VT

50

Vermont

VA

51

Virginia

WA

53

Washington

WV

54

West Virginia

WI

55

Wisconsin

WY

56

Wyoming

GU

66

Guam

PR

72

Puerto Rico

Release Schedule#

Release Date Schedule

2024-10-21

2025-01-27

2025-04-21

2025-07-21

2025-10-27