I am working on simulating resource deployments within arcpy network analyst. I have individual incidents stored in a file database (they have to remain single because later on the script must do a check to ensure there is a resource to deploy. My problem is with the iteration. The first closest facility analysis works but then the script fails before completing the next one. It returns
arcgisscripting.ExecuteError: A python error occurred. Failed to execute (FindClosestFacilities).
This is my code snippet below
import arcpy import time arcpy.env.workspace = r"c:\Simulation\incidents.gdb" arcpy.env.overwriteOutput = True start = time.clock() arcpy.CheckOutExtension("Network") featureclasses = arcpy.ListFeatureClasses() print featureclasses for fc in featureclasses: arcpy.env.workspace = r"c:\Simulation\incidents.gdb" arcpy.env.overwriteOutput = True inNetworkDataset = r"c:\Simulation\tempFGDB.gdb\deccan_street\deccan_street_ND" inIncidents = fc inFacilities = r"c:|Simulation\proposed_csl.shp" outGeodatabase = r"c:\Simulation\NA_outputs.gdb" outRoutes = "Routes" outDirections ="Directions" outClosestFacilities = "ClosestFacilities" measurement_units = "Minutes" with arcpy.da.SearchCursor(fc,("DATE_TIME", "OBJECTID")) as cursor: for row in cursor: vALUE = str(row) # Run FindClosestFacilities. Choose to find only the closest facility. arcpy.na.FindClosestFacilities(fc, inFacilities, measurement_units, inNetworkDataset, outGeodatabase, outRoutes + "_" + vALUE, outDirections + "_" + vALUE, outClosestFacilities + "_" + vALUE, Number_of_Facilities_to_Find=1) print "Script completed successfully" elapsed = (time.clock() - start) print("Execution time: " + str(elapsed))