Update Analysis Layer Attribute Parameter (Network Analyst)

Summary

Updates the network attribute parameter value for a network analysis layer. The tool should be used to update the value of an attribute parameter for a network analysis layer prior to solving with the Solve tool. This ensures that the solve operation uses the specified value of the attribute parameter to produce appropriate results.

Usage

Syntax

UpdateAnalysisLayerAttributeParameter_na (in_network_analysis_layer, parameterized_attribute, attribute_parameter_name, {attribute_parameter_value})
ParameterExplanationData Type
in_network_analysis_layer

Network analysis layer for which the attribute parameter value will be updated.

Network Analyst Layer
parameterized_attribute

The network attribute whose attribute parameter will be updated.

String
attribute_parameter_name

The parameter of the network attribute that will be updated. The parameters of type Object cannot be updated using the tool.

String
attribute_parameter_value
(Optional)

The value that will be set for the attribute parameter. It can be a string, number, date, or Boolean (True, False). If the value is not specified, then the attribute parameter value is set to Null.

TipTip:

If the parameter value holds an array, separate the items in the array with whatever the localized separator character is currently set to. For example, in the U.S., you would most likely use the comma character to separate the items. So representing an array of three numbers might look like "5,10,15".

String

Code Sample

UpdateAnalysisLayerAttributeParameter example 1 (Python window)

Execute the tool using all the parameters.

import arcpy
arcpy.UpdateAnalysisLayerAttributeParameter_na("Route","HeightRestriction",
                                               "MaxHeight",12.0)
UpdateAnalysisLayerAttributeParameter example 2 (workflow)

The following stand-alone Python script demonstrates how the UpdateAnalysisLayerAttributeParameter tool can be used to find the best route that avoids low clearance overpasses or tunnels for certain vehicles.

# Name: UpdateAnalysisLayerAttributeParameter_Workflow.py
# Description: Find the best route that avoids low clearance overpasses or 
#              tunnels for certain vehicles and save results to a layer file.
# Requirements: Network Analyst Extension 
# Author: ESRI

#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 = "C:/data/RhodeIsland.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    outNALayer = "BestTruckRoute"
    impedanceAttribute = "TravelTime"
    accumulateAttribute = ['Length']
    parameterizedAttribute = "HeightRestriction"    
    restrictions = ["Oneway", parameterizedAttribute, "TurnRestriction"]
    searchTolerance = "2000 Meters"
    parameterName = "VehicleHeight"
    truckHeight = 15
    inStops = "Analysis/DeliveryLocations"
    outLayerFile = "C:/data/output" + "/" + outNALayer + ".lyr"
    
    #Make a new route layer. Along with the total travel time, we also want to
    #find out the total distance. So we accumulate "Length" attribute. We want 
    #to obey the oneway, turn restrictions and since we are routing trucks that
    #need a particular clearence, we want to use Height restriction.
    arcpy.MakeRouteLayer_na(inNetworkDataset, outNALayer, impedanceAttribute, 
                            "", "", "", accumulateAttribute,"NO_UTURNS",
                            restrictions)
    
    #Load the Delivery locations as stops using default field map
    arcpy.AddLocations_na(outNALayer, "Stops", inStops, "", searchTolerance)
    
    #As we wish to route trucks which require a clearance of 15 meters,
    #we will set the VehicleHeight parameter on HeightRestriction attribute.
    #This would mean that all streets which have a clearance of less than 15 
    #meters will be restricted.
    arcpy.UpdateAnalysisLayerAttributeParameter_na(outNALayer, 
                                                   parameterizedAttribute,
                                                   parameterName, truckHeight)
    
    #Solve the route layer
    arcpy.Solve_na(outNALayer)
    
    #Save the solved route layer as a layer file on disk using relative paths
    arcpy.SaveToLayerFile_management(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)

Environments

Related Topics

Licensing Information

ArcView: Requires Network Analyst
ArcEditor: Requires Network Analyst
ArcInfo: Requires Network Analyst

Published 6/7/2010