0

The following picture shows the location of the files I need for the Closest Facility Analysis. enter image description here

What's wrong with my code?

import arcpy


arcpy.env.workspace = r"C:\Users\TL\Desktop\test\2.gdb"
inNetworkDataset = "C:\Users\TL\Desktop\test\2.gdb\network\network_ND"
inIncidents = r'G_Fac'
inFacilities = r'HighwayJunctions'
outGeodatabase = r"C:\Users\TL\Desktop\test\2.gdb"
outRoutes = "Routes"
outDirections = "Directions"
outClosestFacilities = "ClosestFacilities"
measurement_units = "Feet"

# Run FindClosestFacilities. Choose to find only the closest facility.
arcpy.na.FindClosestFacilities(inIncidents, inFacilities, measurement_units,
                                    inNetworkDataset, outGeodatabase, outRoutes,
                                    outDirections, outClosestFacilities,
                                    Number_of_Facilities_to_Find=1)

print "Script completed successfully"

The error I got:

Traceback (most recent call last):
  File "<editor selection>", line 14, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\na.py", line 2630, in FindClosestFacilities
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Network Dataset: Dataset C:\Users\TL\Desktop  est.gdb
etwork
etwork_ND does not exist or is not supported
Failed to execute (FindClosestFacilities).
0

1 Answer 1

2

Does it really say: "C:\Users\TL\Desktop est.gdb"?

You might need to put an r in front on the " in inNetworkDatset.

inNetworkDataset = r"C:\Users\TL\Desktop\test\2.gdb\network\network_ND"

Slashes are escape characters.

Another option would be to reverse the \ to /:

"C:/Users/TL/Desktop/test/2.gdb/network/network_ND"
1
  • You are right. Also, I add a field for time measurement and the code works.
    – Tianxin Li
    Sep 2, 2016 at 20:32

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.