applyTravelMode
汇总
用于访问服务区网络分析图层中的分析属性。 GetSolverProperties 函数用于从服务区网络分析图层获取 ServiceAreaSolverProperties 对象。
讨论
ServiceAreaSolverProperties 对象提供对服务区网络分析图层中所有分析属性的读取和写入权限。该对象可用于修改服务区图层的分析属性,并可重新求解相应图层以确定合适结果。使用 创建服务区分析图层 地理处理工具可创建新的服务区图层。通过从新的服务区图层获取 ServiceAreaSolverProperties 对象,可重新对现有图层进行后续分析,而无需每次分析都创建一个图层,以节省时间。
修改 ServiceAreaSolverProperties 对象的属性后,相应的图层可立即与其他函数和地理处理工具配合使用。无需刷新或更新图层,通过上述对象进行的修改便可生效。
语法
applyTravelMode()
属性
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
accumulators (读取和写入) |
用于获取或设置累积为分析一部分的网络成本属性的列表。 空列表 |
String |
|
attributeParameters (读取和写入) |
用于获取或设置将在分析中使用的参数化属性。 该属性返回一个 Python 字典。 该字典关键字是由属性名称和参数名称这两个值组成的元组。 字典中每个项目的值均为参数值。 参数化的网络属性用于对属性值的某个动态方面进行建模。 例如,可使用某个参数对高度限制为 12 英尺的隧道进行建模。 在这种情况下,应将以英尺为单位的车辆高度指定为参数值。 如果车辆高度超过 12 英尺,此限制条件将评估为 尝试修改 请勿尝试修改
使用新的字典对象修改
如果网络分析图层没有参数化属性,则该属性将返回 |
Dictionary |
|
defaultBreaks (读取和写入) |
用于获取或设置要计算的服务区范围的默认阻抗值。 可以设置多个面中断来创建同心服务区。 例如,要查找同一设施点的 2 分钟、3 分钟和 5 分钟服务区域,将值指定为 [2, 3, 5] 。 |
Double |
|
excludeSources (读取和写入) |
用于获取或设置生成面时要排除的网络源的列表。 将从所有面中忽略来自排除源的遍历元素的几何。 空列表 [] 表示不排除任何网络源。 |
String |
|
ignoreInvalidLocations (读取和写入) |
指定是否忽略无效的输入位置。 通常,如果无法 在网络上定位 ,则位置无效。 当无效位置被忽略时,求解程序将跳过它们并尝试使用剩余位置执行分析。
|
String |
|
impedance (读取和写入) |
用于获取或设置用作阻抗的网络成本属性。 在确定服务区域时累积该成本属性。 |
String |
|
includeNetworkSourceFields (读取和写入) |
控制是否将分析期间遍历的基础源要素中的附加字段添加到服务区线。 以下是可能值列表:
|
String |
|
lineOverlap (读取和写入) |
控制计算服务区线时是否生成重叠线。 以下是可能值列表:
|
String |
|
lineType (读取和写入) |
用于获取或设置要从分析中生成的服务区线类型。 以下是可能值列表:
|
String |
|
polygonMerge (读取和写入) |
控制是否合并共享相似中断值的面。 此选项仅适用于为多个设施点生成面的情况。 以下是可能值列表:
|
String |
|
polygonNesting (读取和写入) |
控制是否将同心服务区面创建为圆盘或圆环。 仅当为设施点指定多个中断值时,此选项才适用。 以下是可能值列表:
|
String |
|
polygonType (读取和写入) |
用于获取或设置要生成的面类型。 以下是可能值列表:
|
String |
|
restrictions (读取和写入) |
用于获取或设置适用于分析的约束属性的列表。 空列表 |
String |
|
solverName (只读) |
返回被用于获取求解程序属性对象的网络分析图层所引用的求解程序的名称。 从 |
String |
|
splitLinesAtBreaks (读取和写入) |
控制服务区线在跨越中断值时是否拆分。 以下是可能值列表:
|
String |
|
timeOfDay (读取和写入) |
用于获取或设置离开或到达设施点的时间。 对该值的解释取决于行驶方向是朝向设施点还是远离设施点。 如果 可使用以下日期来指定一周中的每一天,而无需使用特定的日期:
例如,要指定应该在星期五 8:00 a.m. 离开设施点,则将值指定为 datetime.datetime(1900, 1, 5, 8,0,0) 。
|
DateTime |
|
timeZoneUsage (读取和写入) |
指定
无论 |
String |
|
travelDirection (读取和写入) |
控制服务区分析期间阻抗累积的方向。 以下是可能值列表:
|
String |
|
travelMode (只读) |
访问网络分析图层上设置为 |
Object |
|
trimDistance (读取和写入) |
用于获取或设置对服务区面进行修剪的距离范围。 属性值包括距离的数值和单位,用空格分隔;例如,要指定 100 米的修剪距离,使用 "100 Meters" 。 |
String |
|
trimPolygons (读取和写入) |
控制是否对服务区面进行修剪。 以下是可能值列表:
|
String |
|
useHierarchy (读取和写入) |
当执行分析时控制等级属性的使用。 以下是可能值列表:
|
String |
|
uTurns (读取和写入) |
用于获取或设置策略,该策略指示求解程序如何管理停靠点之间的遍历网络期间所产生的交汇点处的 U 形转弯。 以下是可能值列表:
|
String |
方法
applyTravelMode(travel_mode)
根据出行模式对象更新网络分析图层的分析属性。随后可对更新的网络分析图层进行求解以完成分析。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
travel_mode |
该变量引用一个源自网络数据集的出行模式对象。可通过调用 |
Object |
代码示例
该脚本显示如何通过完整的工作流来更新服务区求解程序属性。其基于旧金山地区的教程网络数据集。
# Name: ServiceAreaSolverProperties_Workflow.py
# Description: Finds the regions fire stations can reach within four minutes
# as the initial assessment of the coverage of the region. We will
# then change the break values to 1, 4, and 10 minutes to see a
# better picture of coverage
# Requirements: Network Analyst extension
# Import system modules
import arcpy
from arcpy import env
import os
import datetime
try:
# Set environment settings
output_dir = r"C:\Data"
# The NA layer's data will be saved to the workspace specified here
env.workspace = os.path.join(output_dir, "Output.gdb")
env.overwriteOutput = True
# Set local variables
input_gdb = "C:/Data/SanFrancisco.gdb"
network = os.path.join(input_gdb, "Transportation", "Streets_ND")
layer_name = "FireHouseRegions"
travel_mode = "Driving Time"
direction = "FROM_FACILITIES"
cutoffs = 4
in_facilities = os.path.join(input_gdb, "Analysis/FireStations")
four_minute_polygons = os.path.join(output_dir, "Output.gdb", "four_minute_polygons")
ten_minute_polygons = os.path.join(output_dir, "Output.gdb", "ten_minute_polygons")
# Create a new Service Area layer. Fire stations are concerned with the
# drive times away from the fire stations to the incidents.
result_object = arcpy.na.MakeServiceAreaAnalysisLayer(network,
layer_name, travel_mode,
direction, cutoffs)
# Get the layer object form the result object. The service area layer
# can now be referenced using the layer object.
layer_object = result_object.getOutput(0)
# Get the names of all the sublayers within the service area layer.
sub_layer_names = arcpy.na.GetNAClassNames(layer_object)
# Store the layer names that we will use later
facilities_layer_name = sub_layer_names["Facilities"]
polygons_layer_name = sub_layer_names["SAPolygons"]
# Load the fire station locations as facilities.
arcpy.na.AddLocations(layer_object, facilities_layer_name, in_facilities,
"", "")
# Solve the service area layer
arcpy.na.Solve(layer_object)
# Save the resulting polygon sublayer
arcpy.management.CopyFeatures(polygons_layer_name, four_minute_polygons)
# Get the solver properties object from the service area layer
solverProps = arcpy.na.GetSolverProperties(layer_object)
# Update the breaks to 1, 4, and 10 minutes
solverProps.defaultBreaks = [1, 4, 10]
# Solve the service area layer
arcpy.na.Solve(layer_object)
# Save the resulting polygon sublayer
arcpy.management.CopyFeatures(polygons_layer_name, ten_minute_polygons)
except Exception as e:
# If an error occurred, print line number and error message
import traceback
import sys
tb = sys.exc_info()[2]
print("An error occurred on line %i" % tb.tb_lineno)
print(str(e))
此脚本显示如何将 TruckingTime 出行模式应用到现有图层。
#Get the service area layer object from a layer named "Service Area" in the map
doc = arcpy.mp.ArcGISProject('current')
map_obj = doc.listMaps()[0]
sa_layer = map_obj.listLayers('Service Area')[0]
#Get the Trucking Time travel mode from the network dataset
desc = arcpy.Describe(sa_layer)
travel_modes = arcpy.na.GetTravelModes(desc.network.catalogPath)
trucking_mode = travel_modes["Trucking Time"]
#Apply the travel mode to the analysis layer
solver_properties = arcpy.na.GetSolverProperties(sa_layer)
solver_properties.applyTravelMode(trucking_mode)