创建最近设施点分析图层 (网络分析)
摘要
创建最近设施点网络分析图层并设置其分析属性。最近设施点分析图层可用于根据指定的网络成本确定与事故点距离最近的设施点。
用法
语法
| 参数 | 说明 | 数据类型 |
in_network_dataset |
要执行最近设施点分析的网络数据集。 | Network Dataset Layer |
out_network_analysis_layer |
要创建的最近设施点网络分析图层的名称。 | String |
impedance_attribute |
分析过程中用作阻抗的成本属性。 | String |
travel_from_to (可选) |
指定设施点与事件点之间的行驶方向。
如果网络具有单向限制和因行驶方向而异的阻抗,则使用此选项可在该网络上查找其他设施点。例如,从事件点行驶到设施点时,可能需要 10 分钟,而从设施点行驶到事件点时,可能因该方向上的行驶时间不同而需要 15 分钟。 消防部门通常使用 TRAVEL_FROM 设置,因为他们需要关注从消防站(设施点)行驶到紧急救援位置(事件点)所需的时间。零售商店(设施点)则更关注顾客(事件点)到达商店所需的时间;因此,商店通常使用 TRAVEL_TO 选项。 | String |
default_cutoff (可选) |
停止为指定事件点搜索设施点时对应的默认阻抗值。可通过以下方式来覆盖该默认值:在使用 TRAVEL_TO 选项时,指定事件点的中断值;或者在使用 TRAVEL_FROM 选项时,指定设施点的中断值。 | Double |
default_number_facilities_to_find (可选) |
要按事件点查找的默认最近设施点数。可通过为事件点的 TargetFacilityCount 属性指定一个值来覆盖该默认值。 | Long |
accumulate_attribute_name [accumulate_attribute_name,...] (可选) |
分析过程中要累积的成本属性的列表。这些累积属性仅供参考;求解程序仅使用阻抗属性参数所指定的成本属性来计算路径。 For each cost attribute that is accumulated, a Total_[Impedance] property is added to the routes that are output by the solver. | String |
UTurn_policy (可选) |
限制或允许停靠点间网络遍历过程中可能出现在交汇点处的 U 形转弯。
| String |
restriction_attribute_name [restriction_attribute_name,...] (可选) |
分析过程中要应用的约束属性的列表。 | String |
hierarchy (可选) |
如果未在用于执行分析的网络数据集中定义等级属性,该参数将不可用。在这种情况下,使用“#”作为参数值。 | Boolean |
hierarchy_settings (可选) |
旧版本:在版本 10 之前,可使用此参数将网络数据集中建立的默认等级范围更改为其他范围以用于分析。而版本 10 中不再支持此参数,并且应将其指定为空字符串。如果您要更改等级范围以进行分析,请更新网络数据集中的默认等级范围。 | Network Analyst Hierarchy Settings |
output_path_shape (可选) |
为分析所输出的路径要素指定形状类型。
无论选择何种输出 shape 类型,最佳路径始终由网络阻抗(而非欧氏距离)决定。这表示只是路径形状不同,而对网络进行的基础遍历则相同。 | String |
代码示例
仅使用必需参数执行此工具
import arcpy
arcpy.env.workspace = "C:/ArcTutor/Network Analyst/Tutorial/SanFrancisco.gdb"
arcpy.MakeClosestFacilityLayer_na("Transportation/Streets_ND",
"ClosestFireStations","Minutes")
使用所有参数执行此工具
import arcpy
arcpy.env.workspace = "C:/ArcTutor/Network Analyst/Tutorial/SanFrancisco.gdb"
arcpy.MakeClosestFacilityLayer_na("Transportation/Streets_ND",
"ClosestHospitals","Minutes","TRAVEL_TO",5,3,
["Meters","Minutes"],"ALLOW_UTURNS",
["Oneway"],"USE_HIERARCHY","",
"TRUE_LINES_WITH_MEASURES")
以下独立 Python 脚本演示了如何使用 MakeClosestFacilityLayer 工具查找距商店位置最近的仓库。
# Name: MakeClosestFacilityLayer_Workflow.py
# Description: 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 with
#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)