解析レイヤの属性パラメータの更新(Update Analysis Layer Attribute Parameter) (Network Analyst)
サマリ
ネットワーク解析レイヤのネットワーク属性パラメータ値を更新します。このツールは、[解析の実行(Solve)] ツールで解析を実行する前に、ネットワーク解析レイヤの属性パラメータの値を更新するために使用する必要があります。これにより、解析操作において指定した属性パラメータの値が確実に使用され、適切な結果を得ることができます。
使用法
- 
パラメータ化されたネットワーク属性は、リアルタイムに変化する属性値をモデリングするために使用されます。たとえば、12 フィートの車高規制があるトンネルをパラメータを使用してモデリングできます。この場合、車両の高さ(フィート)をパラメータ値として指定する必要があります。この規制は車両の高さが 12 フィートを超える場合に true に評価されます。同様に、橋は重量規制を指定するパラメータを保持することができます。 
- 
このツールは、定義されたパラメータが設定されたネットワーク属性を持つネットワーク解析レイヤのみに使用される必要があります。 
- 
このツールは、ネットワーク解析レイヤで解析を実行する前に、繰り返し既存のパラメータの値を変更するのに使用できます。 
- 
カタログ ウィンドウまたは ArcCatalog のネットワーク データセット プロパティ ダイアログ ボックスで、新しい属性パラメータを作成することができます。 
構文
| パラメータ | 説明 | データ タイプ | 
| in_network_analysis_layer | 属性パラメータが更新されるネットワーク解析レイヤ。 | Network Analyst Layer | 
| parameterized_attribute | 属性パラメータが更新されるネットワーク属性。 | String | 
| attribute_parameter_name | 更新されるネットワーク属性のパラメータ。このツールでは、Object タイプのパラメータは更新できません。 | String | 
| attribute_parameter_value (オプション) | 属性パラメータに設定される値。文字列、数値、日付、またはブール値(True、False)のいずれかになります。値が指定されていない場合、属性パラメータ値は NULL に設定されます。 属性パラメータに規制使用タイプがある場合、文字列キーワードまたは数値で値を指定できます。この文字列キーワードまたは数値により、規制属性が、それに関連付けられたネットワーク エレメントを禁止するのか、回避するのか、優先するのかが決まります。さらに、HIGH、MEDIUM、または LOW キーワードを選択することによって、ネットワーク エレメントを回避または優先する度合いを定義できます。以下のキーワードがサポートされています。 
 数値が 1 より大きい場合は、規制されたエレメントが回避されます。数値が大きいほど、多くのエレメントが回避されます。数値が 0 ~ 1 の場合は、規制されたエレメントが優先されます。数値が小さいほど、多くの規制されたエレメントが優先されます。数値がマイナスの場合は、規制されたエレメントが禁止されます。  ヒント: パラメータ値に複数の値を指定する場合は、設定されている区切り文字を使用して、各値を区切ってください。たとえばアメリカ合衆国では、項目の区切り文字としてカンマをよく使用します。3 つの数字を「5,10,15」のように表します。 | String | 
コードのサンプル
すべてのパラメータを使用してツールを実行します。
import arcpy
arcpy.na.UpdateAnalysisLayerAttributeParameter("Route", "Height Restriction",
                                               "Vehicle Height (feet)", 12.0)
次のスタンドアロン Python スクリプトは、解析レイヤの属性パラメータの更新(Update Analysis Layer Attribute Parameter)ツールを使用して、車両に対する高さ制限が低い高架またはトンネルを避け、有料道路を回避し、指定されたトラックのルートを優先する、トラックの最適ルートを検索する方法を示しています。
# Name: UpdateAnalysisLayerAttributeParameter_Workflow.py
# Description: Find the best route for trucks that avoids low clearance 
#              overpasses or tunnels, avoids toll roads and prefers desginated
#              truck routes. The results are saved 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/SanDiego.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    outNALayerName = "BestTruckRoute"
    impedanceAttribute = "TravelTime"
    accumulateAttribute = ['Meters']
    tollRoadRestriction = "Avoid Toll Roads"
    preferTruckRouteRestriction = "National STAA Preferred Route"
    parameterName = "Restriction Usage"
    inStops = "Analysis/Customers"
    outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
    
    #Make a new route layer. Along with the total travel time, we also want to
    #find out the total distance. So we accumulate "Meters" attribute. We will
    #create the route layer with defaultrestrictions and add the additional 
    #restrictions that we want the routes to honor.
    outNALayer = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                         impedanceAttribute, "", "", "",
                                         accumulateAttribute,"NO_UTURNS")
    #Get the layer object from the result object. The route layer can 
    #now be referenced using the layer object.
    outNALayer = outNALayer.getOutput(0)
    
    #Get the names of all the sublayers within the route layer.
    subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
    #Stores the layer names that we will use later
    stopsLayerName = subLayerNames["Stops"]
    
    #Modify the restriction attributes for the route layer. We don't want to use
    #Driving an Automobile restriction and wan't to use Driving a Truck,
    #Avoid Toll Roads and National STAA Preferred Route restrictions.
    solverProperties = arcpy.na.GetSolverProperties(outNALayer)
    defaultRestrictions = solverProperties.restrictions
    defaultRestrictions.remove("Driving an Automobile")
    defaultRestrictions += ["Driving a Truck", tollRoadRestriction,
                            preferTruckRouteRestriction]
    solverProperties.restrictions = defaultRestrictions
    
    #Load the Delivery locations as stops using default field mappings
    arcpy.na.AddLocations(outNALayer, stopsLayerName, inStops, "", "")
    
    #As we wish avoid toll roads as much as possible and highly prefer the 
    #designated turck routes, we set the appropriate parameter values for the 
    #Restriction Usage parameter for these two restriction attributes.
    arcpy.na.UpdateAnalysisLayerAttributeParameter(outNALayer, tollRoadRestriction,
                                                   parameterName, "AVOID_HIGH")
    arcpy.na.UpdateAnalysisLayerAttributeParameter(outNALayer,
                                                   preferTruckRouteRestriction,
                                                   parameterName, "PREFER_HIGH")
    
    #Solve the route layer
    arcpy.na.Solve(outNALayer)
    
    #Save the solved route layer as a layer file on disk using relative paths
    arcpy.management.SaveToLayerFile(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)