[GIS] Calculate distance using 2 sets of lat/long values in the same record

arcgis-10.2arcgis-desktopdistancelatitude longitude

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?

Best Answer

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!)