Network Analyst のライセンスで利用可能。
サマリー
ルート ネットワーク解析レイヤーを作成し、解析プロパティを設定します。ルート解析レイヤーは、指定したネットワーク コストに基づいて、ネットワーク ロケーション間の最適ルートを決定する際に役立ちます。
使用法
- このツールで解析レイヤーを作成した後は、[ロケーションの追加 (Add Locations)] ツールを使用して解析レイヤーにネットワーク解析オブジェクトを追加し、[解析の実行 (Solve)] ツールを使用して解析を実行し、[レイヤー ファイルの保存 (Save To Layer File)] ツールを使用して結果をディスクに保存することができます。 
- このツールをジオプロセシング モデルに使用するときは、モデルをツールとして動作させる場合、出力ネットワーク解析レイヤーにモデル パラメーターを作成する必要があります。そうしないと、出力レイヤーはマップのコンテンツに追加されません。 
構文
MakeRouteLayer_na (in_network_dataset, out_network_analysis_layer, impedance_attribute, {find_best_order}, {ordering_type}, {time_windows}, {accumulate_attribute_name}, {UTurn_policy}, {restriction_attribute_name}, {hierarchy}, {hierarchy_settings}, {output_path_shape}, {start_date_time})| パラメーター | 説明 | データ タイプ | 
| in_network_dataset | ルート解析が実行されるネットワーク データセット。 | Network Dataset Layer | 
| out_network_analysis_layer | 作成するルート ネットワーク解析レイヤーの名前。 | String | 
| impedance_attribute | 解析でインピーダンスとして使用されるコスト属性。 | String | 
| find_best_order (オプション) | 
 | Boolean | 
| ordering_type (オプション) | FIND_BEST_ORDER を使用するときに、ストップの順番を指定します。 
 | String | 
| time_windows (オプション) | ストップでタイム ウィンドウが使用されるかどうかを指定します。 
 | Boolean | 
| accumulate_attribute_name [accumulate_attribute_name,...] (オプション) | 解析中に累積されるコスト属性のリスト。これらの累積属性は、参考情報としてのみ使用されます。解析では、[インピーダンス] 属性パラメーターで指定されているコスト属性のみを使用してルートを計算します。 累積されるコスト属性ごとに、解析で出力されたルートに [Total_[Impedance]] プロパティが追加されます。 | String | 
| UTurn_policy (オプション) | ジャンクションでの U ターン ポリシー。U ターンを許可するということは、解析においてジャンクションで方向転換し、同じ道路を引き返すことができるということを意味します。ジャンクションが道路の交差と行き止まりを表すことを前提に、さまざまな車両が、一部のジャンクションでは方向転換でき、他のジャンクションでは方向転換できない、というように設定できます。これは、ジャンクションが交差と行き止まりのどちらを表すかによって変わります。これに対応するには、ジャンクションに接続するエッジの数 (ジャンクションでのノードへの接続数) によって、暗黙的に U ターン ポリシーを指定します。以下では、このパラメーターで選択できる値と、ジャンクションので接続におけるそれぞれの意味について示します。 
 U ターン ポリシーをさらに正確に定義する必要がある場合、グローバル ターン遅延エバリュエーターをネットワーク コスト属性に追加するか、すでに存在する場合はそれを調整することを検討してください。その際、逆ターンの設定には特に注意が必要です。また、ネットワーク ロケーションの CurbApproach プロパティの設定についても調べてください。 | String | 
| restriction_attribute_name [restriction_attribute_name,...] (オプション) | 解析中に適用される規制属性のリスト。 | String | 
| hierarchy (オプション) | 
 解析を実行するネットワーク データセットに使用する階層属性が定義されていない場合、パラメーターは使用されません。この場合、「"#"」をパラメーター値として使用します。 | Boolean | 
| hierarchy_settings (オプション) | Network Analyst Hierarchy Settings | |
| output_path_shape (オプション) | 解析で出力されるルート フィーチャの形状タイプを指定します。 
 どの出力形状のタイプを選択するかに関係なく、常に最適なルートはユークリッド距離ではなくネットワーク インピーダンスによって決定されます。ネットワーク解析の結果は同じですが、ルート形状のみが異なります。 | String | 
| start_date_time (オプション) | ルートの開始日時を指定します。ルートの開始時間は多くの場合、1 日の時刻に応じて変化するインピーダンス属性に基づいたルートの検索に使用されます。たとえば、ラッシュアワーの交通量を考慮したルートの検索には午前 7 時が開始時間として使用されることがあります。このパラメーターのデフォルト値は、午前 8 時です。日時は、10/21/05 10:30 AM のように指定できます。ルートが複数日にわたり、開始時間のみが指定されている場合、現在の日付が使用されます。 特定の日付を使用する代わりに、次の日付を使用して曜日を指定することができます。 
 解析後、出力ルートにはルートの開始時間と終了時間が挿入されます。このような開始時間と終了時間は、ルート案内の生成時にも使用されます。 | Date | 
コードのサンプル
MakeRouteLayer (ルート レイヤーの作成) の例 1 (Python ウィンドウ)
必須パラメーターのみを使用してツールを実行します。
network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeRouteLayer(network, "WorkRoute", "TravelTime")
MakeRouteLayer (ルート レイヤーの作成) の例 2 (Python ウィンドウ)
すべてのパラメーターを使用してツールを実行します。
network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeRouteLayer(network, "InspectionRoute", "TravelTime",
                        "FIND_BEST_ORDER", "PRESERVE_BOTH", "USE_TIMEWINDOWS",
                        ["Meters", "TravelTime"],
                        "ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY", ["Oneway"],
                        "USE_HIERARCHY", "", "TRUE_LINES_WITH_MEASURES",
                        "1/1/1900 9:00 AM")
MakeRouteLayer (ルート レイヤーの作成) の例 3 (ワークフロー)
次のスタンドアロン Python スクリプトは、MakeRouteLayer (ルート レイヤーの作成) ツールを使用して、ジオコーディングされたストップ ロケーションを巡回する最適ルートを検索する方法を示しています。
# Name: MakeRouteLayer_Workflow.py
# Description: Find a best route to visit the stop locations and save the 
#              route to a layer file. The stop locations are geocoded from a 
#              text file containing the addresses.
# 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/SanFrancisco.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    outNALayerName = "BestRoute"
    impedanceAttribute = "TravelTime"
    inAddressLocator = "SanFranciscoLocator"
    inAddressTable = "C:/data/StopAddresses.csv"
    inAddressFields = "Street Address VISIBLE NONE"
    outStops = "GeocodedStops"
    outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
    
    #Create a new Route layer. For this scenario, the default value for all the
    #remaining parameters statisfies the analysis requirements
    outNALayer = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                         impedanceAttribute)
    
    #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"]
    
    #Geocode the stop locations from a csv file containing the addresses.
    #The Geocode Addresses tool can use a text or csv file as input table
    #as long as the first line in the file contains the field names.
    arcpy.geocoding.GeocodeAddresses(inAddressTable, inAddressLocator, 
                                     inAddressFields, outStops)
    
    #Load the geocoded address locations as stops mapping the address field from
    #geocoded stop features as Name property using field mappings.
    fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
    fieldMappings["Name"].mappedFieldName = "Address"
    arcpy.na.AddLocations(outNALayer, stopsLayerName, outStops, fieldMappings,
                          "", exclude_restricted_elements = "EXCLUDE")
    
    #Solve the route layer, ignore any invalid locations such as those that
    #can not be geocoded
    arcpy.na.Solve(outNALayer,"SKIP")
    
    #Save the solved route layer as a layer file on disk with 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 occurred on line %i" % tb.tb_lineno
    print str(e)
MakeRouteLayer (ルート レイヤーの作成) の例 4 (ワークフロー)
この例では、1 つの解析で複数のルートを作成します。これは多くの場合、起点と終点の間の距離または運転時間の計算に使用されます。
# Name: MakeRouteLayer_MultiRouteWorkflow.py
# Description: Calculate the home-work commutes for a set of people and save
#              the output to a feature class
# Requirements: Network Analyst Extension
import datetime
#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/SanFrancisco.gdb"
    env.overwriteOutput = True
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    inStops_Home = "Analysis/Commuters_Home"
    inStops_Work = "Analysis/Commuters_Work"
    outNALayerName = "Commuters"
    outRoutesFC = "Analysis/outRoutes"
    impedanceAttribute = "TravelTime"
    #Set the time of day for the analysis to 8AM on a generic Monday.
    start_time = datetime.datetime(1900, 1, 1, 8, 0, 0)
    #Create a new Route layer.  Optimize on TravelTime, but compute the
    #distance traveled by accumulating the Meters attribute.
    outRouteResultObject = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName,
                                         impedanceAttribute,
                                         accumulate_attribute_name=["Meters"],
                                         hierarchy="NO_HIERARCHY",
                                         start_date_time=start_time)
    #Get the layer object from the result object. The route layer can now be
    #referenced using the layer object.
    outNALayer = outRouteResultObject.getOutput(0)
    #Get the names of all the sublayers within the route layer.
    subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
    #Store the layer names that we will use later
    stopsLayerName = subLayerNames["Stops"]
    routesLayerName = subLayerNames["Routes"]
    #Before loading the commuters' home and work locations as route stops, set
    #up field mapping.  Map the "Commuter_Name" field from the input data to
    #the RouteName property in the Stops sublayer, which ensures that each
    #unique Commuter_Name will be placed in a separate route.  Matching
    #Commuter_Names from inStops_Home and inStops_Work will end up in the same
    #route.
    fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
    fieldMappings["RouteName"].mappedFieldName = "Commuter_Name"
    #Add the commuters' home and work locations as Stops. The same field mapping
    #works for both input feature classes because they both have a field called
    #"Commuter_Name"
    arcpy.na.AddLocations(outNALayer, stopsLayerName, inStops_Home,
                        fieldMappings, "",
                        exclude_restricted_elements = "EXCLUDE")
    arcpy.na.AddLocations(outNALayer, stopsLayerName, inStops_Work,
                        fieldMappings, "",
                        exclude_restricted_elements = "EXCLUDE")
    #Solve the route layer.
    arcpy.na.Solve(outNALayer)
    # Get the output Routes sublayer and save it to a feature class
    RoutesSubLayer = arcpy.mapping.ListLayers(outNALayer, routesLayerName)[0]
    arcpy.management.CopyFeatures(RoutesSubLayer, outRoutesFC)
    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: はい