Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Good Day,

I'm having trouble debugging my python code to create a network analyst layer in ArcGIS 10.0. Basically when run from a script tool the code completes successfully without actually doing anything or returning any sort of useful information, and when run from the embedded python window in ArcGIS 10.0 i get the following error.

"Runtime error : Failed to execute. Parameters are not valid. ERROR 000192: Invalid value for Time Attribute Failed to execute (MakeVehicleRoutingProblemLayer)."

The script is supposed to solve the route and create a layer file for the output Here is my code below:

#Import system modules
import arcpy
from arcpy import env

try:
    #Check out the Network Analyst extension license
    arcpy.CheckOutExtension("Network")

    #Set environment settings
    env.workspace = r'C:\Layout3.gdb'
    env.overwriteOutput = True

    #Set local variables
    inNetworkDataset = r'C:\Layout3.gdb\NtsFDS\NtsFDS_ND'
    outNALayerName = "TestResult"

    impedanceAttribute = "CABLE_COST"
    distanceAttribute = "TRAVEL_TIME"
    timeUntis = "Minutes"
    distanceUntis = "Meters"
    inOrders = r'\Layout3.gdb\NtsFDS\Orders'
    inDepots = r'C:\Layout3.gdb\NtsFDS\Depots'
    inRoutes = r'C:\Layout3.gdb\NtsFDS\Route'
    outLayerFile = env.workspace + outNALayerName + ".lyr"

    outNALayer = arcpy.na.MakeVehicleRoutingProblemLayer(inNetworkDataset, outNALayerName,
                                                         impedanceAttribute,
                                                         distanceAttribute)

    outNALayer = outNALayer.getOutput(0)


    subLayerNames = arcpy.na.GetNAClassNames(outNALayer)

    ordersLayerName = subLayerNames["Orders"]
    depotsLayerName = subLayerNames["Depots"]
    routesLayerName = subLayerNames["Routes"]

    candidateFields = arcpy.ListFields(inOrders)
    orderFieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, ordersLayerName,
                                                       False, candidateFields)
    arcpy.na.AddLocations(outNALayer, ordersLayerName, inOrders, orderFieldMappings,"")


    depotFieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, depotsLayerName)
    arcpy.na.AddLocations(outNALayer, depotsLayerName, inDepots, depotFieldMappings, "")

    arcpy.na.AddLocations(outNALayer, routesLayerName, inRoutes, "", "")

    #Solve the VRP layer
    arcpy.na.Solve(outNALayer)

    #Save the solved VRP layer as a layer file on disk with relative paths
    arcpy.management.SaveToLayerFile(outNALayer,outLayerFile,"RELATIVE")

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)
share|improve this question
    
The runtime error occurs when i try to use the MakeVehicleRoutingProblemLayer function –  IQ_HiGh May 14 '13 at 7:38
add comment

1 Answer 1

For this code to run you will need to upgrade to ArcGIS 10.1 because the ArcPy Network Analyst module (arcpy.na) was only introduced at that release.

share|improve this answer
    
Thanks but that blows big time... –  IQ_HiGh May 14 '13 at 13:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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