更新分析图层属性参数 (网络分析)

摘要

更新网络分析图层的网络属性参数值。在使用求解工具求解前,应使用该工具更新网络分析图层的属性参数值。此操作将确保求解操作使用属性参数的特定值生成恰当的结果。

用法

语法

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)。如果未指定值,则属性参数值将被设置为空。

提示提示:

如果参数值包含一个数组,不管当前设置为何种本地分隔符,都要用其分隔数组中的各项。例如,在美国,最有可能使用逗号分隔项目。因此表示包含三个数值的数组可以是“5,10,15”

String

代码示例

UpdateAnalysisLayerAttributeParameter 示例 1(Python 窗口)

使用所有参数执行工具。

import arcpy
arcpy.UpdateAnalysisLayerAttributeParameter_na("Route","HeightRestriction",
                                               "MaxHeight",12.0)
UpdateAnalysisLayerAttributeParameter 示例 2(工作流)

以下独立 Python 脚本演示了如何使用 UpdateAnalysisLayerAttributeParameter 工具查找避免某些车辆经过低间距天桥或隧道的最佳路径。

# 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 

#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)

环境

相关主题


7/10/2012