2

I am trying to calculate network distance from 10 points within 896 polygons "SA1s" (a total of 8960 facilities), each to ten points within 186 polygons "DZNs" (a total of 1860 incidents). I would like to iterate over each of the 896 facility groups (each has it's own feature class, containing 10 points (I would undertake some post-processing of these feature classes, deleting the main outputs with each one.

The iteration is not particularly problematic, but I'm having a problem with the actual python script running over a single iteration.

I set up a script in Model Builder on a test set of data (10 facilities from one SA1 to 10 incidents from one DZN) and ran it - it ran perfectly. I then deleted the outputs and exported the model to a python script, shown below:

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("Network")


# Local variables:
Incidents = "in_memory\\{DC034A5A-77FD-4B9E-BD36-ECDE5ABD576B}"
Facilities = "in_memory\\{0AA3C7A5-47AA-494D-B97E-6C5A25C7F522}"
in_memory = "in_memory"
Point_Barriers = "in_memory\\{DDEAEEC2-AAD9-4B99-9D69-1020AEEF8B6F}"
Line_Barriers = "in_memory\\{C7F6D7A5-B9FB-447B-8373-E98398408F2C}"
Polygon_Barriers = "in_memory\\{40ABDBEB-B48B-4C95-8354-9C3DFB60EDB9}"
Attribute_Parameter_Values = "in_memory\\{D84163A6-7A47-419B-B8FF-79420ABC0651}"
DZN_Test_Points =    "C:\\Users\\xgoldie\\Desktop\\ModeShare_Study\\Mode_Share_Study.gdb\\DZN_Test_Points"
SA1_Test_Points = "C:\\Users\\xgoldie\\Desktop\\ModeShare_Study\\Mode_Share_Study.gdb\\SA1_Test_Points"
ACT_Road_Network_ND_nd = "C:\\Users\\xgoldie\\Desktop\\ModeShare_Study\\ACT_Road_Network_ND.nd"
Mode_Share_Study_gdb = "C:\\Users\\xgoldie\\Desktop\\ModeShare_Study\\Mode_Share_Study.gdb"

# Process: Find Closest Facilities
arcpy.FindClosestFacilities_na(DZN_Test_Points, SA1_Test_Points, "Meters", ACT_Road_Network_ND_nd, Mode_Share_Study_gdb, "Routes_Test", "Directions_Test", "ClosestFacilities_Test", "10", "", "TRAVEL_TO", "", "NOT_USED", "GEO_LOCAL", "ALLOW_UTURNS", Point_Barriers, Line_Barriers, Polygon_Barriers, "Minutes", "Minutes", "Meters", "Meters", "NO_HIERARCHY", "", Attribute_Parameter_Values, "", "20 Kilometers", "\"ACT_Road_Network\" #;\"ACT_Road_Network_ND_Junctions\" #", "TRUE_LINES_WITH_MEASURES", "10 Meters", "NO_DIRECTIONS", "", "Miles", "", "", "", "", "", "", "", "", "NO_SAVE_OUTPUT_LAYER")

I then attempted to run it again from IDLE, and it failed. Giving me the following error message:

Traceback (most recent call last):
  File "C:\Users\xgoldie\Desktop\SCRIPTS\networkanalyst.py", line 30, in <module>
    arcpy.FindClosestFacilities_na(DZN_Test_Points, SA1_Test_Points, "Meters", ACT_Road_Network_ND_nd, Mode_Share_Study_gdb, "Routes_Test", "Directions_Test", "ClosestFacilities_Test", "10", "", "TRAVEL_TO", "", "NOT_USED", "GEO_LOCAL", "ALLOW_UTURNS", Point_Barriers, Line_Barriers, Polygon_Barriers, "Minutes", "Minutes", "Meters", "Meters", "NO_HIERARCHY", "", Attribute_Parameter_Values, "", "20 Kilometers", "\"ACT_Road_Network\" #;\"ACT_Road_Network_ND_Junctions\" #", "TRUE_LINES_WITH_MEASURES", "10 Meters", "NO_DIRECTIONS", "", "Miles", "", "", "", "", "", "", "", "", "NO_SAVE_OUTPUT_LAYER")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\na.py", line 2595, in FindClosestFacilities
    raise e
ExecuteError: A geoprocessing error occurred.
Failed to execute. Parameters are not valid.
ERROR 000735: Input Rows: Value is required
Failed to execute (GetCount).
Failed to execute (FindClosestFacilities).

Does anyone why this is occuring, and how to fix it?

  • 1
    I am not 100% sure, but can you really have those {DC034A5A-77FD-4B9E-BD36-ECDE5ABD576B} for defining variable names in Python code? Perhaps replace them with a string ("temp_layername"). I would recommend opening manually a GP tool in Network Analyst toolbox > define the parameters > run it > make sure it worked fine > go to Results window > right-click > Copy as Python Snippet > try this chunk of code. Should help if when exporting from ModelBuilder some of the parameters value gone or get invalid. – Alex Tereshenkov Oct 10 '14 at 5:37
  • I've fixed that component, but the problem now is the temporary facilities layer from the first iteration prevents me from doing the next round: Traceback (most recent call last): ExecuteError: A geoprocessing error occurred. Failed to execute. Parameters are not valid. ERROR 000725: Output Layer: Dataset OrigInputFacilitiesLayer already exists. Failed to execute (MakeFeatureLayer). Failed to execute (FindClosestFacilities). – Xavier Goldie Oct 10 '14 at 12:52
  • 1
    just use the arcpy.env.overwriteOutput = True. Or delete objects first before trying to write them over :) – Alex Tereshenkov Oct 10 '14 at 13:55
  • Yes I threw the error code into Google and found the overwrite answer last night - working swimmingly now! Thanks very much for your help – Xavier Goldie Oct 10 '14 at 21:35
  • I have wrapped up my comments as an answer you can vote and acccept. – Alex Tereshenkov Oct 11 '14 at 6:16
2

I don't think you can name your feature classes as those {DC034A5A-77FD-4B9E-BD36-ECDE5ABD576B} for defining variable names in Python code. You should perhaps replace them with a string ("temp_layername"). I would recommend opening manually a GP tool in Network Analyst toolbox > define the parameters > run it > make sure it worked fine > go to Results window > right-click > Copy as Python Snippet > try this chunk of code. Should help if when exporting from ModelBuilder some of the parameters value gone or get invalid.

If having troubles overwriting existing objects, use arcpy.env.overwriteOutput = True for the env settings.

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.