Calculating Geodesic Distance Between Points

Going back to the very early days of ArcGIS there have been geoprocessing tools for calculating distances between features. Tools like Near, Point Distance, and Buffer have been around for many releases, and perform key analysis in a number of common GIS workflows. These distance-measuring tools have always worked well and calculated very accurate distances for features concentrated in a relatively small area (a city, state, or single UTM zone) with an appropriate projected coordinate system that minimizes distance distortion. Unfortunately, for groups of features spread over larger areas (regions, countries, or the world!), or for datasets with a geographic coordinate system, these tools have historically produced results that were less than perfect.

In the last few releases, and continuing in future releases, more emphasis has been placed on calculating accurate distances for that second scenario: features covering a large area, or datasets with a geographic coordinate system. Some key enhancements are in the works to make distance measurement through geoprocessing better than ever, namely by calculating geodesic distances in the scenarios described above (geodesic distance is the distance measured along the shortest route between two points on the Earth’s surface).

In 10.0 Service Pack 2, an enhancement has been made to enable the calculation of geodesic distance along a line. This is done with a line feature class in a geographic coordinate system using the Calculate Field tool and specifying an expression like !Shape.length@meters! . This functionality can be included in a longer workflow to calculate geodesic distance between points.

The model summarized below produces output similar to the Generate Near Table tool; given Input Points and Near Points datasets, find the geodesic distance from each input point to each near point and record that distance in a new table. You can download this model and sample data from the Geoprocessing Resource Center Model and Script Tool Gallery here, and run the tool with your own point datasets that have a geographic coordinate system (some modification to the model may be required).

Since this geodesic distance calculation relies on the measurement of lines, we need a way to create line features between all input points and near points. The XY To Line tool can be used to accomplish this, but first there are a few steps that must be done to setup the workflow and produce a table that can be used with the XY To Line tool. Given that the XY To Line tool requires a table of XY coordinates as input, first add XY coordinate information to both the Input Points and Near Points using the Add XY Coordinates tool.

Next, use the Generate Near Table tool to setup what will become the Output Table (note that the NEAR_DIST values produced by the Generate Near Table tool are in decimal degrees – not geodesic distances).

After creating the Output Table, use the Join Field tool to move the coordinate information from the Input Points and Near Points to the Output Table. Also, a unique identifier field will be required later, so add a new ID field using Add Field and calculate it equal to the Output Table ObjectID field using Calculate Field.

Now that the Output Table is set up to be used correctly with the XY To Line tool (with Start and End coordinates stored in separate fields), run XY To Line to create line features between each input point and near point. These will be the lines that can be measured to obtain geodesic distances.

Output of XY To Line

Next, add a new model variable, Linear Unit, which can be used to specify the unit in which to calculate the geodesic distance (meters, kilometers, feet, miles, etc.). Then add a new field ‘GEO_DIST’ and calculate it as the geodesic distance along the lines using a calculation expression!Shape.length@%Linear Unit%!, then join these distances back to the Output Table. Finally, clean up the Output Table by deleting any unnecessary or intermediate fields.

The output of the workflow will look like the table pictured below, where the field GEO_DIST contains the geodesic distance between the points identified in the IN_FID and NEAR_FID fields, in the unit specified in the Linear Unit variable. Comparing these geodesic distances to Euclidean distances (based on a Mercator projection) shows how inaccurate distance measurements can be if they are performed in an inappropriate coordinate system or at an inappropriate scale.

Geodesic distances calculated by this model, and Euclidean distances calculated by the Generate Near Table tool.

This entry was posted in Analysis & Geoprocessing and tagged , , , , . Bookmark the permalink.

Leave a Reply


  1. nickmcw says:

    Good news, thanks for the post. A couple of questions please…

    Will this functionality be available in the attribute table field calculator?

    And will these methods work ONLY for data in geographic (unprojected) coordinates? With projected data, it would be nice to have a choice of whether to measure distance across the projection plane, or along the geodesic surface.

    Thanks in advance -

  2. mtnbykerchic says:

    This is a very helpful article…now for those of us that are still using 9.3, is there a model we could employ to do this as well? Definitely interested in finding out how to utilize tools like Point Distance tool or Generate Near Table and produce geodetic results.

  3. mtnbykerchic says:

    PS…is there a way to print these blogs out in a nice format? I’m getting all the extra stuff (links down the side) which makes the printout longer and requires a landscape print.

  4. drewf says:

    For your first question: yes, you can execute the same Python command in the attribute table field calculator. The field calculate actually calls the Calculate Field geoprocessing tool (you can see your calculations in the Result window), so the functionality the same between the two methods. For your second question: this will only work for data in a geographic coordinate system. We are working on enabling geodesic measurement for a number of tools, and in both projected and geographic coordinate systems, but this won’t be available until after 10.1.


  5. drewf says:

    This workaround requires ArcGIS Desktop 10.0 SP2. To my knowledge there is no way to do something like this in 9.3. The Point Distance and Generate Near Table tools do not calculate geodesic distances, but we are working to enhance these and other tools with this ability in a future release (post 10.1).
    As for printing the blog, there is no way to make a nice printable version automatically, but you can try copying and pasting into a word processing program, but that will require some formatting on your part to make it fit like you want. Also, some of the nicer bloggers put the source document in with the gallery download :)


  6. drewf says:

    This comment was submitted through the Contact Us link, but others may have the same question so I am responding here.

    “This process sounds like exactly what I need. However, I do not have ArcInfo (which is apparently needed for Generate Near Table, among other steps). I have ArcView 10.0, Service Pack 2. Is there a way to calculate geodesic distances using that?”

    Thank you for your question, I’m glad this functionality applies to the work you are doing. You are correct that many of the tools involved in this workflow require an ArcInfo license, including Generate Near Table and Join Field. You should be able to adjust the workflow to accomplish these same goals. For example, instead of using the Join Field tool, use the Add Join tool to create a temporary join, then the Remove Join tool to remove that join when finished (Add Join and Remove Join are both ArcView level tools).

    Like I mention in the blog, the Generate Near Table tool is really only used to set up the output table, not to actually perform any of the measurement analysis (it is interesting for comparison, but the calculated values are not used in calculating geodesic distance). This tool was the most efficient way to set up a matrix-style table containing all the from and to points — if you don’t know what I mean you can look at the tool’s help page for further description. However, there are probably alternatives for setting up a table of this nature. If you are familiar with scripting, this would involve reading all of the input points’ ObjectIDs, then creating a new table that looks like the first Output Table above.

    Good luck!