I have what is hopefully a fairly simple question.

I am trying to run an OD cost matrix for every minute of a day for research I am performing. All of the settings will be the same for each run, except the time will change. I will be automating the process in Python. I know how to create a cost matrix with the settings, add the locations, and solve it all using Arcpy. However, I am hoping to be able to just change the time setting for each run without having to create a whole new cost matrix and add the locations again (similar to what you can do manually in ArcMap).

I have not been able to find a way to do this in Python (if there even is a way).

  • 2
    Can you provide your python code so far and tell us what has worked and hasn't worked in it? – dassouki Jul 21 '13 at 17:13
  • Everything works in my code so far. For example, I have it set up to run an OD matrix for my origins/destinations on a Monday at 8:00am. In Arcpy, the only way I can figure out how to run an OD matrix on a Monday at 8:01am is to create a whole new OD matrix and load all of my locations again. I was just wondering if there was a way to just change the time setting of an OD matrix without having the create a whole new one and load locations again. – britterj Jul 21 '13 at 17:16
  • You might find this question helpful. – Paul Jul 21 '13 at 17:27
  • Paul, Thanks for pointing that article out. I already read it and it might be the route I will have to take, but that solution still requires me to create a new OD matrix and add my locations again for each new time. There is probably no other way to do, but I was hoping to just find a way to change an OD matrix settings in arcpy without actually creating a new matrix, if that makes sense. – britterj Jul 21 '13 at 17:33
  • Yes, I see what you are trying to do. Sadly, it doesn't seem possible based on how the tool is set up. – Paul Jul 21 '13 at 17:45

If anyone is still interested in this, I ended up finding the solution:

The ODCostMatrixSolverProperties object provides read and write access to all the analysis properties of an OD cost matrix network analysis layer. The object can be used to modify the desired analysis properties of the OD cost matrix layer, and the corresponding layer can be re-solved to determine the appropriate results. A new OD cost matrix layer can be created using the Make OD Cost Matrix Layer geoprocessing tool. Obtaining the ODCostMatrixSolverProperties object from a new OD cost matrix layer allows you to reuse the existing layer for subsequent analyses rather than create a new layer for each analysis, which can be slow.

After modifying the properties on the ODCostMatrixSolverProperties object, the corresponding layer can be immediately used with other functions and geoprocessing tools. There is no refresh or update of the layer required to honor the changes modified through the object.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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