I have a feature dataset and want to find the cost of travel between each pair of features. Because I'm looking for road (not Euclidean) distances, I was told that the OD Cost Matrix solver in Network Analyst is the way to find the costs in ArcGIS. However, if my dataset has n features, the solver produces an n**2 x 1 matrix, whereas I need an n x n matrix, where each row and column represents a feature and each row-column intersection holds the travel cost between the two features.

Can Network Analyst format its output in this way? If not, what is the easiest way of obtaining such a square matrix?

1 Answer 1


No, it cannot. You would have to run the solver and then do some table manipulation on the result. The result should be giving you at least three columns - origin FID, destination FID, and distance. You would need to sort/select everything by origin FID and export each unique origin FID to a new table. Once you have your n tables, you'd use something like Transpose Fields on them to convert all those rows into a single one with multiple columns. Your fields would be the destination FIDs. Once each table is collapsed into a single row, you can then combine them all back into a single table. By sorting the rows by increasing value, and ensuring the columns are ordered the same, you should be able to generate the matrix you want. It's possible this table manipulation may be easier in a spreadsheet program. Or someone else might have a faster/easier method, since this kind of matrix is very common in atlases and gazetteers showing travel distances between major cities.

  • In fact, the OD Cost Matrix output puts the origin and destination into the same column (a cell in it might literally say, "Location3 -- Location4", for example). So, in addition to everything you mentioned, it looks like I have to first split the contents of that column into two different columns... Like you've said, what I'm trying to achieve here isn't all that uncommon. I can't believe there is no faster or easier way of accomplishing it.
    – Mhoram
    Commented Nov 20, 2015 at 19:11
  • Never mind, the data DO have separate fields for origin and destination IDs. I am still surprised that there is no easier way to create square matrices, though.
    – Mhoram
    Commented Nov 20, 2015 at 21:06
  • 1
    Possible approach gis.stackexchange.com/questions/169034/…
    – FelixIP
    Commented Nov 21, 2015 at 2:19
  • Sounds like a good candidate for an ArcGIS Idea. I see one that is similar but not specific to the Network Analyst extension (or OD Cost Matrix in particular).
    – Chris W
    Commented Nov 21, 2015 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.