### Prepared by David G. Tarboton, Utah State University, Sept 2005

A common task working with geographic data is the calculation of the distance between two points on the surface of the earth.  For points close together the earth surface may be approximated as a plane using a convenient projection, but as points get further apart the approximation involved with a projection becomes less accurate and it is better to calculate the distance along an arc around the surface of the earth.  In performing this calculation the earth may be approximated as a spheroid, or if more precise results are required as an ellipsoid.  We will illustrate some of these methods to calculate the distance between points along the Hurricane Katrina track.

1.  Distance using a projection on to a flat plane.  Load the Feature Classes KatrinaPath and States into Arcmap to obtain a display similar to the following:

Note that in the coordinate display at the bottom coordinates are expressed in latitude and longitude.  This lets you know that this map display is in terms of geographic coordinates.  This can be verified by right clicking on  the table of contents "Layers" label referred to as a data frame and selecting properties.

In the Properties dialog that appears select the coordinate system tab to see that the coordinate system is GCS_North_American_1983.

This means a Geographic Coordinate system using latitude and longitude coordinates relative to the North American Datum of 1983 (NAD83).  Click on Predefined/Projected/Continental/North America and select "USA Contiguous Equidistant Conic".  I am guessing that this is a projection that preserves distances well (by the equidistant in the name).  Click OK.

Your Map display should now adjust itself so that meters are shown in the coordinate display at the bottom.  The map is now being displayed using projected coordinates.

In projected coordinates it is meaningful to select the Measure tool and measure distances between points as shown above.  The distance between two points on the Hurricane track, such as the 8/28 10 pm and 8/29 10 am points shown can be read as 288117 m, or 288 km.  This distance is somewhat approximate due to inaccuracy in positioning the Measure tool precisely over the points.

To more precisely calculate this distance we need the coordinates of each of these points in projected coordinates.  To achieve this we first need to create a new feature class that is in projected coordinates.  Right click on Katerina path and select Data/Export data as shown below

Click on use the same coordinate system as the data frame and browse to output a feature class in the geodatabase named 'katrina.mdb' giving the new feature class the name KatrinaProj.  Click OK and click Yes to add the features to the map.

The new feature class now displayed on the map has its coordinates saved internally in projected coordinates rather than geographic coordinates.  To retrieve these coordinates so that distance calculations can be performed the ArcGIS "Field Calculations" capability will be used.  This is explained in ArcGIS help on "Making Field Calculations".

Open the attribute table for the feature class KatrinaProj.  Click Options/Add field and add a new field named X of type Double.

Your table should now include a new field containing <null> values.

In ArcMap click on the Tools Menu and select Editor Toolbar.  On the editor toolbar click start editing and start editing the KatrinaProj feature class.  Now back on the table right click on the header label to the new field X and select Calculate Values.

In the Field Calculator Click on Advanced and enter the VBA script shown in the text boxes.  (This is following the steps in the help file).

Click OK.  X coordinate values should appear in the attribute table.  Use a similar sequence of steps to create a field of Y coordinates.  The capability to add fields is only enabled when editing is turned off, so you will need to turn editing off on the Editor toolbar, create the new field then use the Field calculator to calculate Y coordinates.  The result is:

Geometry can be used to more precisely calculate the distances between the points.  Between the points of 8/28 10 pm and 8/29 10 am the distance is:

m = 288.8 km.  This is a bit more precise than the measure distance obtained above.

#### 2.Distance on a curved earth represented as a spheroid.

Refer to http://en.wikipedia.org/wiki/Spherical_distance for a discussion of this.  This source gives the following formula for calculating the "Great Circle" distance between two points.

This formula is equivalent to the haversine formula linked at the above page, but expressed not quite as concisely using more conventional trigonometric functions.

Implementing this formula in Excel for the two points above I get a distance of 289.58 km.  The radius of the earth was taken as 6367 km in the below and angles were converted to radians.  (This is an embeddded Excel object so you can see the formula's if you download the Word document).

#### 3.Distance on a curved earth represented as an ellipsoid.

The earth is better approximated as an ellipsoid than a spheroid.  MATLAB script exchange includes an implementation of a function for calculating distances on the WGS84 reference ellipsoid.  This is given at http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5379&objectType=FILE.  Evaluating this function in MATLAB I get

vdist(27.6, -89.4, 30.2, -89.6)

ans =  2.8883e+005

This reports the distance between the two points as 288.83 km.  I believe this ellipsoid distance to be the most precise.  This is quite close to the projected coordinate distance, but not as close to the great circle distance.  Therefore I conclude that distances calculated in projected coordinates are more precise at this scale than great circle distances.