需要 Network Analyst 许可。
摘要
更新网络分析图层的网络属性参数值。在使用求解工具求解前,应使用该工具更新网络分析图层的属性参数值。此操作将确保求解操作使用属性参数的特定值生成恰当的结果。
用法
参数化的网络属性用于对属性值的某个动态方面进行建模。例如,可使用某个参数对高度限制为 12 英尺的隧道进行建模。在这种情况下,应将以英尺为单位的车辆高度指定为参数值。这样,如果车辆高度大于 12 英尺,则此限制的计算结果将为真。类似的,桥梁还可以具有一个用来指定重量限制的参数。
此工具仅适用于定义了参数化的网络属性的网络分析图层。
求解网络分析图层前,可使用该工具重复更改现有参数的值。
新属性参数可通过目录窗口或 ArcCatalog 中的网络数据集属性对话框创建。
语法
UpdateAnalysisLayerAttributeParameter_na (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 关键字来定义。可支持的关键字如下:
大于一的数值会避开限制元素;数值越大,避开的元素就越多。零和一之间的数值会导致优先选择限制元素;数值越小,优先选择的限制元素就越多。负值会禁止限制元素。 | String |
代码示例
更新分析图层属性参数 (UpdateAnalysisLayerAttributeParameter) 示例 1(Python 窗口)
使用所有参数执行工具。
arcpy.na.UpdateAnalysisLayerAttributeParameter("Route", "Height Restriction",
"Vehicle Height (feet)", 12.0)
更新分析图层属性参数 (UpdateAnalysisLayerAttributeParameter) 示例 2(工作流)
以下独立 Python 脚本演示了如何使用“更新分析图层属性参数”工具来查找卡车为了避开低间距天桥或隧道、避开收费公路并且优先选择指定的货车路径而采用的最佳路径。
# 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 occurred on line %i" % tb.tb_lineno
print str(e)
环境
许可信息
- ArcGIS Desktop Basic: 是
- ArcGIS Desktop Standard: 是
- ArcGIS Desktop Advanced: 是