Update Analysis Layer Attribute Parameter (Network Analyst)

License Level:BasicStandardAdvanced

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.

If the attribute parameter has a restriction usage type, the value can be specified as a string keyword or a numeric value. The string keyword or the numeric value determines whether the restriction attribute prohibits, avoids, or prefers the network elements it is associated with. Furthermore, the degree to which network elements are avoided or preferred can be defined by choosing HIGH, MEDIUM, or LOW keywords. The following keywords are supported:

  • PROHIBITED
  • AVOID_HIGH
  • AVOID_MEDIUM
  • AVOID_LOW
  • PREFER_LOW
  • PREFER_MEDIUM
  • PREFER_HIGH

Numeric values that are greater than one cause restricted elements to be avoided; the larger the number, the more the elements are avoided. Numeric values between zero and one cause restricted elements to be preferred; the smaller the number, the more restricted elements are preferred. Negative numbers prohibit restricted elements.

TipTip:

If the parameter value holds an array, separate the items in the array with the localized separator character. 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 the following: "5,10,15".

String

Code Sample

UpdateAnalysisLayerAttributeParameter example 1 (Python window)

Execute the tool using all the parameters.

arcpy.na.UpdateAnalysisLayerAttributeParameter("Route", "Height Restriction",
                                               "Vehicle Height (feet)", 12.0)
UpdateAnalysisLayerAttributeParameter example 2 (workflow)

The following stand-alone Python script demonstrates how the Update Analysis Layer Attribute Parameter tool can be used to find the best route for trucks that avoid low clearance overpasses or tunnels, avoid toll roads, and prefer designated truck routes.

# Name: UpdateAnalysisLayerAttributeParameter_Workflow.py
# Description: Use the network dataset's length and height restriction attribute
#               parameters to find a route suitable for transporting a large
#               wind turbine blade. The results are saved to a layer file.
# Requirements: Network Analyst Extension 

#Import system modules
import arcpy
from arcpy import env
import os

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

    #Set environment settings
    env.workspace = "C:/Data/SanDiego.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    network = "Transportation/Streets_ND"
    layer_name = "WindTurbineRoute"
    impedance = "Meters"
    restrictions = ["Driving a Truck", "Height Restriction", "Oneway",
            "Length Restriction", "National STAA and Locally Preferred Routes"]
    seaport = "Analysis/Port"
    wind_farm = "Analysis/WindFarm"
    output_layer_file = os.path.join(r"C:/Data", layer_name + ".lyr")

    #Make a new route layer. Use restriction attributes relevant to trucking
    #oversize loads
    result_object = arcpy.na.MakeRouteLayer(network, layer_name, impedance,
                                        restriction_attribute_name=restrictions)
    
    #Get the layer object from the result object. The route layer can 
    #now be referenced using the layer object.
    layer_object = result_object.getOutput(0)
    
    #Set the vehicle height and length attribute parameters to the dimensions of
    #the wind turbine transport truck. If these dimensions exceed the limits
    #associated with a street feature, that street will be restricted, and the
    #resulting route will avoid it.
    arcpy.na.UpdateAnalysisLayerAttributeParameter(layer_object,
                        "Height Restriction", "Vehicle Height (feet)", 13.25)
    arcpy.na.UpdateAnalysisLayerAttributeParameter(layer_object,
                        "Length Restriction", "Vehicle Length (feet)", 80)
    
    #Load the origin and destination points as Stops in the Route
    sublayer_names = arcpy.na.GetNAClassNames(layer_object)
    stops_layer_name = sublayer_names["Stops"]
    arcpy.na.AddLocations(layer_object, stops_layer_name, seaport, "", "")
    arcpy.na.AddLocations(layer_object, stops_layer_name, wind_farm, "", "",
                            append="APPEND")
    
    #Solve the route layer
    arcpy.na.Solve(layer_object)
    
    #Save the solved route layer as a layer file on disk
    arcpy.management.SaveToLayerFile(layer_object, output_layer_file,
                                        "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

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
1/20/2015