arcpy.na.UpdateAnalysisLayerAttributeParameter(in_network_analysis_layer, parameterized_attribute, attribute_parameter_name, {attribute_parameter_value})
|
名称
|
说明
|
数据类型
|
|
in_network_analysis_layer
|
要更新属性参数值的网络分析图层。
|
Network Analyst Layer
|
|
parameterized_attribute
|
要更新属性参数的网络属性。
|
String
|
|
attribute_parameter_name
|
要更新的网络属性的参数。 “对象”类型的参数不能使用该工具进行更新。
|
String
|
|
attribute_parameter_value
(可选)
|
要为属性参数设置的值。 该值可以是字符串、数值、日期或布尔值(True 和 False)。 如果未指定值,则属性参数值将被设置为空。
如果属性参数为限制使用类型,则参数值可被指定为字符串关键字或数值。 字符串关键字或数值决定了限制属性是否禁止、避开或优先选择与之关联的网络元素。 并且,网络元素避开或优先选择的程度可通过选择 HIGH、MEDIUM、或 LOW 关键字来定义。 可支持的关键字如下:
PROHIBITED
AVOID_HIGH
AVOID_MEDIUM
AVOID_LOW
PREFER_LOW
PREFER_MEDIUM
PREFER_HIGH
大于一的数值会避开限制元素;数值越大,避开的元素就越多。 零和一之间的数值会导致优先选择限制元素;数值越小,优先选择的限制元素就越多。 负值会禁止限制元素。
提示:
如果参数值包含一个数组,则使用本地分隔符分隔数组中的项目。 例如,在美国,最有可能使用逗号分隔项目。 因此,表示包含三个数值的数组时可以显示为:"5,10,15"。
|
String
|
派生输出
|
名称
|
说明
|
数据类型
|
|
output_layer
|
已更新的网络分析图层。
|
Network Analyst Layer
|
代码示例
UpdateAnalysisLayerAttributeParameter 示例 1(Python 窗口)
使用所有参数运行此工具
arcpy.na.UpdateAnalysisLayerAttributeParameter("Route", "Height Restriction",
"Vehicle Height (feet)", 12.0)
UpdateAnalysisLayerAttributeParameter 示例 2(工作流)
以下独立 Python 脚本演示了如何使用 UpdateAnalysisLayerAttributeParameter 函数来查找货车为了避开低间距天桥或隧道、避开收费公路并且优先选择指定的货车路径而采用的最佳路径。
# 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:
#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)))