# Calculate distance using 2 sets of lat/long values in the same record

I have a point layer with over 90K records in it. For each record I have lat/long field for incident, and lat/long for engine location. Is there a way to find the distance between Incident point and Engine Location point?

So far, I created points using "Make XY Event layer" using lat/long for incidents. And again I run the same tool for Engine locations. When I run the Near tool in ArcGIS it will find the nearest engine point around the incident and will give me the distance to the nearest engine but not necessarily the distance from the engine location on the same record. How can I calculate distances using the lat/long values for incident and engine location in the same record?

• Welcome to GIS.SE! Could you edit your question to include which version of ArcMap this is?
– Paul
Commented Jul 22, 2014 at 19:15
• Hi I am using ArcGIS 10.2.2. Commented Jul 22, 2014 at 21:21

Here's one way it can be done:

1. Change your data frame to a projected coordinate system that makes sense for your data.
2. Calculate Geometry on 4 new fields X_incident, X_engine, Y_incident, Y_engine to populate the coordinates, using the CS of the data frame. Don't use the default, which is the coordinate system of the data!
3. Calculate distance field with `math.hypot(!X_incident!-!X_engine!, !Y_incident!-!Y_engine!)`
• Hi Paul, I just noticed my coordinate values are not in lat/long but they are in Easting and Northing format. In order to do the calculation do I need to convert them to lat long first? if so what is the best way to do that in ArcGIS? Thanks Commented Jul 22, 2014 at 21:23
• @user34904 Generally, you want your data in a projected coordinate system when making linear measurements. A distance of 0.021435° usually isn't desired, so you'll want your coordinates in feet or meters, for instance.
– Paul
Commented Jul 22, 2014 at 21:29

Depending on the version/license of ArcGIS, you could use the 'XY to line' tool, in the 'data management\feature' toolbox. it produces a line feature from two sets of coordinates in a single table, which sounds like exactly what you are trying to do.

If you project your data to a planar coordinate system in linear units (feet, meters) you could use the old pythagorean theorem. Note: This is not going to do the type of thing you'd get with network analyst (this will be euclidean distance aka "as the crow flies"). Lets say your fields are x1, y1, x2, y2. You'd create another set of fields and calculate them to be the square root of the Absolute value of x12 minus x22 plus the absolute value of y12 minus y22.

If you ARE using network analyst, I would try using a duplicate of the layer. Even if it gives you more point to point distances than you need, you can join them back together using a tabular join.