解析の実行(Solve) (Network Analyst)
サマリ
指定したネットワーク ロケーションとプロパティに基づいて、ネットワーク解析レイヤを実行します。
使用法
-
解析が失敗すると、警告およびエラー メッセージにより失敗の原因に関する有用な情報が表示されます。
-
このツールを実行する前に、解析の実行に必要なネットワーク解析レイヤのすべてのパラメータを必ず指定してください。
構文
Solve_na (in_network_analysis_layer, {ignore_invalids}, {terminate_on_solve_error})
| パラメータ | 説明 | データ タイプ |
in_network_analysis_layer |
解析が実行されるネットワーク解析レイヤ。 | Network Analyst Layer |
ignore_invalids (オプション) |
配車ルート ネットワーク解析レイヤの場合、すべてのネットワーク ロケーションが有効である必要があるため、HALT(中止)をパラメータ値に使用します。 | Boolean |
terminate_on_solve_error (オプション) |
| Boolean |
コードのサンプル
Solve(解析の実行)の例 1(Python ウィンドウ)
すべてのパラメータを使用してツールを実行します。
import arcpy
arcpy.Solve_na("Route","HALT","TERMINATE")
Solve(解析の実行)の例 2(ワークフロー)
次のスタンドアロン Python スクリプトは、Solve(解析の実行)ツールを使用して最寄り施設解析を実行し、結果をレイヤ ファイルに保存する方法を示しています。
# Name: Solve_Workflow.py
# Description: Solve a closest facility analysis to find the closest warehouse
# from the store locations and save the results to a layer file on
# disk.
# 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/Paris.gdb"
env.overwriteOutput = True
#Set local variables
inNetworkDataset = "Transportation/ParisMultimodal_ND"
outNALayer = "ClosestWarehouse"
impedanceAttribute = "Drivetime"
accumulateAttributeName = ["Meters"]
inFacilities = "Analysis/Warehouses"
inIncidents = "Analysis/Stores"
fieldMappings = "Name NOM #"
outLayerFile = "C:/data/output" + "/" + outNALayer + ".lyr"
#Create a new closest facility analysis layer. Apart from finding the drive
#time to the closest warehouse, we also want to find the total distance. So
#we will accumulate the "Meters" impedance attribute.
arcpy.MakeClosestFacilityLayer_na(inNetworkDataset,outNALayer,
impedanceAttribute,"TRAVEL_TO","",1,
accumulateAttributeName,"NO_UTURNS")
#Load the warehouses as Facilities using the default field mappings and
#search tolerance
arcpy.AddLocations_na(outNALayer,"Facilities",inFacilities,"","")
#Load the Stores as Incidents. Map the Name property from the NOM field
arcpy.AddLocations_na(outNALayer,"Incidents",inIncidents,fieldMappings,"")
#Solve the closest facility layer
arcpy.Solve_na(outNALayer)
#Save the solved closest facility 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