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.
Legacy:
This is a deprecated tool. Instead of updating your network analysis layer's attribute parameter values individually at analysis time, you should instead set attribute parameter values in advance by configuring travel modes on your network data source. At analysis time, simply choose the correct travel mode.
Usage
Parameterized network attributes are used to model some dynamic aspect of an attribute's value. For example, a tunnel with a height restriction of 12 feet can be modeled using a parameter. In this case, the vehicle's height in feet should be specified as the parameter value. This restriction will then evaluate to true if the vehicle is higher than 12 feet. Similarly, a bridge could have a parameter to specify a weight restriction.
This tool should only be used with network analysis layers having network attributes with parameters defined on them.
This tool can be used to repeatedly change the value of an existing parameter before solving a network analysis layer.
Syntax
arcpy.na.UpdateAnalysisLayerAttributeParameter(in_network_analysis_layer, parameterized_attribute, attribute_parameter_name, {attribute_parameter_value})
Parameter | Explanation | Data 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:
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. Tip: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 |
Derived Output
Name | Explanation | Data Type |
output_layer | The updated network analysis layer. | Network Analyst Layer |
Code sample
Execute the tool using all the parameters.
arcpy.na.UpdateAnalysisLayerAttributeParameter("Route", "Height Restriction",
"Vehicle Height (feet)", 12.0)
The following stand-alone Python script demonstrates how the UpdateAnalysisLayerAttributeParameter 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 Network Analyst license if available. Fail if the Network Analyst license is not available.
if arcpy.CheckExtension("network") == "Available":
arcpy.CheckOutExtension("network")
else:
raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
#Set environment settings
output_dir = "C:/Data"
#The NA layer's data will be saved to the workspace specified here
env.workspace = os.path.join(output_dir, "Output.gdb")
env.overwriteOutput = True
#Set local variables
input_gdb = "C:/Data/SanDiego.gdb"
network = os.path.join(input_gdb, "Transportation", "Streets_ND")
layer_name = "WindTurbineRoute"
impedance = "Meters"
restrictions = ["Driving a Truck", "Height Restriction", "Oneway",
"Length Restriction", "National STAA and Locally Preferred Routes"]
seaport = os.path.join(input_gdb, "Analysis", "Port")
wind_farm = os.path.join(input_gdb, "Analysis", "WindFarm")
output_layer_file = os.path.join(output_dir, layer_name + ".lyrx")
#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
layer_object.saveACopy(output_layer_file)
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 occurred on line %i" % tb.tb_lineno))
print((str(e)))
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes