Route

摘要

此 ArcPy 类用于执行路径分析。

说明

路径分析可用于计算沿某一网络一系列停靠点之间的最短路径。

了解有关路径分析的详细信息

语法

 Route (in_network)
参数说明数据类型
in_network

The network dataset or service that will be used for the network analysis. The argument can be specified using one of the following options:

To use a network dataset, the network must have at least one travel mode.

To use a portal URL, you must be signed in to the portal with an account that has routing privileges.

When using ArcGIS Online or an ArcGIS Enterprise portal whose routing services are configured usingArcGIS Online as the in_network value, solving the analysis will consume credits and will be subject to certain limits, such as the number of allowed inputs.

Learn more about credit consumption and analysis limits in network analysis

String

属性

属性说明数据类型
accumulateAttributeNames
(可读写)

分析过程中要累积的成本属性的列表。 这些累积属性仅供参考;求解程序仅使用求解分析时指定的出行模式所使用的成本属性。

默认值为空列表。

如果网络数据源为不支持累积属性的 ArcGIS OnlineArcGIS Enterprise 门户,设置此属性时会返回一条错误。

String
allowAutoRelocate
(可读写)

指定是否可以在求解时自动重定位具有现有网络位置字段的输入,以确保分析的位置字段有效并且可路由。 如果值为 True,则位于限制网络元素上的点和受障碍影响的点将重定位至最近的可路由位置。 如果值为 False,则网络位置字段将按原样使用(即使点无法访问),并且这可能会导致求解失败。

即使值为 False,没有位置字段或位置字段不完整的输入也会在求解时定位。

默认为 True

此属性会影响所有输入类型的定位。 要更改单个输入类型的此属性,请使用 setLocateSettingsOverrides 方法。

了解有关网络位置字段以及如何在网络中定位输入的详细信息

如果网络数据源是 ArcGIS Online、不支持使用网络位置字段的 ArcGIS Enterprise 门户或运行低于 11.0 的 ArcGIS Enterprise 版本的门户,则设置此属性会返回错误。

Boolean
allowSaveLayerFile
(可读写)

指定是否允许在结果对象上使用 saveAsLayerFile 方法将分析结果另存为图层文件。 值为 True 表明可以保存图层文件。 值为 False 表明无法保存图层文件。 如果分析引用网络数据集,则默认设置为 True;如果其引用门户服务,则为 False。 如果分析引用门户服务,则保存图层文件可能会降低分析速度。

Boolean
allowSaveRouteData
(可读写)

指定是否允许在结果对象上使用 saveRouteData 方法将分析结果保存为 .zip 文件。 值为 True 表明可以保存路径数据。 值为 False 表明无法保存路径数据。 如果分析引用网络数据集,则默认设置为 True;如果其引用门户服务,则为 False。 如果分析引用门户服务,则保存路径数据可能会降低分析速度。

Boolean
directionsDistanceUnits
(可读写)

报告输出转弯方向的行驶距离时使用的单位。 将返回该属性并将其设置为 DistanceUnits 枚举的成员,且仅在 returnDirections 属性为 True 时可用。 默认值是分析时使用的出行模式中距离属性的单位。

Object
directionsLanguage
(可读写)

将显示输出转弯方向文本的语言。 返回该属性并将表示受支持方向语言的两个或五个字符的语言代码之一设置为字符串。 可从 arcpy.nax.ListDirectionsLanguages 函数中获得可用的方向语言列表。 默认值为 en(英语)或当前激活的语言包的语言。 此属性仅在 returnDirections 属性为 True 时可用。

String
directionsStyle
(可读写)

用于输出转弯方向文本的样式。 将返回该属性并将其设置为 DirectionsStyle 枚举的成员,且仅在 returnDirections 属性为 True 时可用。

默认值为 Desktop

Object
distanceUnits
(可读写)

报告分析输出中的行驶距离时使用的单位。 无论网络数据集中成本属性的单位如何,输出都将转换为此属性中设置的单位并以该单位进行报告。 将返回该属性并将其设置为 DistanceUnits 枚举的成员。 默认为 DistanceUnits.Kilometers

Object
findBestSequence
(可读写)

值为 False 表示应按输入中指定的顺序访问停靠点。 值为 True 表示应对输入停靠点重新排序以使总体行驶成本最小化。 此选项将路径分析由最短路径问题变为流动推销员问题 (TSP)。 默认为 False

Boolean
ignoreInvalidLocations
(可读写)

指定是否忽略无效的输入位置。 值为 True 表示将忽略无效的输入位置,仅使用有效位置即可成功进行分析。 值为 False 表示不会忽略无效位置,从而导致分析失败。

旧版本:

基于运行 10.9 之前版本 ArcGIS Enterprise 的门户的路径服务将始终忽略无效的输入位置。 如果将 ignoreInvalidLocations 设置为 False 并且该服务不支持此选项,则此方法将返回 ValueError 异常。

Boolean
networkDataSource
(只读)

网络数据集的完整目录路径或用于分析的服务的 URL。

String
overrides
(可读写)

注:

此属性仅限内部使用。

String
preserveFirstStop
(可读写)

如果由于 findBestSequence 属性设置为 True,而对停靠点进行重新排序,则此属性的 True 值可用于保留第一个停靠点的顺序。 将重新排序其余的停靠点以查找最佳路径。 如果路径从车库或站点开始,此功能将非常有用。 默认为 False

Boolean
preserveLastStop
(可读写)

如果由于 findBestSequence 属性设置为 True,而对停靠点进行重新排序,则此属性的 True 值可用于保留最后一个停靠点的顺序。 将重新排序其余的停靠点以查找最佳路径。 如果路径必须以车库或站点结束,此功能将非常有用。 默认为 False

Boolean
returnDirections
(可读写)

指定是否将生成转弯方向。 值为 True 表明在求解分析时将生成转弯方向。 值为 False 表明不会生成转弯方向。 生成方向可能会降低分析速度。 默认值为 False

Boolean
returnRouteEdges
(可读写)

指定是否将返回路径边。 路径边是单独的路径段,用于指示已遍历的网络边。 值为 True 表示在求解分析时将保存并返回路径边。 值为 False 表示将不会保留路径边。 如果 Route 对象引用网络数据集,则默认设置为 True;如果其引用门户服务,则为 False。 如果分析引用门户服务,则返回路径边可能会降低分析速度。

Boolean
returnRouteJunctions
(可读写)

指定是否返回路径遍历的网络交汇点。 值为 True 表示在求解分析时将保存并返回交汇点。 值为 False 表示将不会保留交汇点。 如果 Route 对象引用网络数据集,则默认设置为 True;如果其引用门户服务,则为 False。 门户服务不支持返回交汇点。

Boolean
returnRouteTurns
(可读写)

指定是否返回路径遍历的网络转弯。 值为 True 表示在求解分析时将保存并返回转弯。 值为 False 表示将不会保留转弯。 如果 Route 对象引用网络数据集,则默认设置为 True;如果其引用门户服务,则为 False。 门户服务不支持返回转弯。

Boolean
returnToStart
(可读写)

值为 True 表示路径最终应返回路径的起始位置。 值为 False 表示路径将在最后一个站点结束。 默认为 False

Boolean
routeShapeType
(可读写)

要生成的表示输出路径的形状类型。 路径始终沿网络计算;但是,您可以选择使用不反映网络路径的形状来表示它们。 将返回该属性并将其设置为 RouteShapeType 枚举的成员。 默认为 RouteShapeType.TrueShapeWithMeasures

Object
searchQuery
(可读写)

旧版本:
此属性已被 searchSources 属性取代,后者是在 ArcGIS Pro 3.0 中引入的。 searchQuery 属性将继续用于保持与现有脚本的向后兼容性,但是建议新版本使用 searchSources 属性。

当在网络中定位输入时,此属性指定查询以将搜索范围限制在源要素类的要素子集内。 这在不想查找可能不适合网络位置的要素时很有用。 例如,如果您不想定位在高速公路坡道上,则可定义一个查询将其排除。

该参数值被指定为具有嵌套列表的列表,其中每个网络源具有一个条目。 每个内部列表由两个值组成,分别表示网络源的名称和用作该源的查询的 SQL 表达式。 空字符串 "" 表示不查询特定源。

例如,值 [["Streets", "ROAD_CLASS <> 3"], ["Streets_ND_Junctions", ""]] 指定了 Streets 源要素类的 SQL 表达式,而没有指定 Streets_ND_Junctions 源要素类的表达式。

如果列表中不包含网络源,则将其解释为无查询。 值 [["Streets", "ROAD_CLASS <> 3"]] 等同于 [["Streets", "ROAD_CLASS <> 3"], ["Streets_ND_Junctions", ""]]

默认情况下,不对任何源使用查询。

了解有关在网络中定位输入的详细信息

有关 SQL 语法的详细信息,请参阅在 ArcGIS 中使用的查询表达式的 SQL 参考

如果网络数据源是 ArcGIS Online 或运行低于 11.0 的 ArcGIS Enterprise 版本的门户,则设置此属性会返回错误。

List
searchSources
(可读写)

当在网络中定位输入时,此属性指定要使用的网络源列表和(可选)查询以将搜索限制为源要素类内的一部分要素。

默认值是在除系统交汇点之外的所有网络源上定位,并覆盖通过运行融合网络工具创建的交汇点。 默认情况下,不对任何源使用查询。

该参数值被指定为具有嵌套列表的列表,每个网络源最多具有一个条目。 每个内部列表由两个值组成,分别表示网络源的名称和用作该源的查询的 SQL 表达式。

网络源组件的可能值为参与网络的边源和交汇点源的字符串要素类名称。 列表中的源将用于定位,而不在列表中的源将不会用于定位。

查询在不想查找可能不适合网络位置的要素时很有用。 例如,如果您不想定位在高速公路坡道上,则可定义一个查询将其排除。 对于查询组件,请参阅在 ArcGIS 中使用的查询表达式的 SQL 参考获取正确表达式。 空字符串 "" 表示不查询特定源。

例如,值 [["Streets", "ROAD_CLASS <> 3"], ["Streets_ND_Junctions", ""]] 指定输入可以位于 StreetsStreets_ND_Junctions 源上。 Streets 源要素类的 SQL 表达式禁止输入位于 ROAD_CLASS 字段的值为 3 的街道上。 不会将查询用于 Streets_ND_Junctions 源要素类。 值 [["Streets", "ROAD_CLASS <> 3"]] 表示应仅将 Streets 源要素类用于定位,不应使用 Streets_ND_Junctions。 此外,还会将查询应用于 Streets

此属性会影响所有输入类型的定位。 要更改单个输入类型的此属性,请使用 setLocateSettingsOverrides 方法。

了解有关在网络中定位输入的详细信息

如果网络数据源是 ArcGIS Online 或运行低于 11.0 的 ArcGIS Enterprise 版本的门户,则设置此属性会返回错误。

String
searchTolerance
(可读写)

在网络上定位输入要素所需的最大搜索距离。 返回该属性并将其设置为双精度,然后通过 searchToleranceUnits 属性访问该值的单位。 默认值为 5000。

此属性会影响所有输入类型的定位。 要更改单个输入类型的此属性,请使用 setLocateSettingsOverrides 方法。

了解有关在网络中定位输入的详细信息

旧版本:

如果网络数据源是运行低于 11.0 的 ArcGIS Enterprise 版本的门户,则设置此属性会返回错误。

Double
searchToleranceUnits
(可读写)

searchTolerance 属性的单位。 将返回该属性并将其设置为 DistanceUnits 枚举的成员。 默认为 DistanceUnits.Meters

此属性会影响所有输入类型的定位。 要更改单个输入类型的此属性,请使用 setLocateSettingsOverrides 方法。

旧版本:

如果网络数据源是运行低于 11.0 的 ArcGIS Enterprise 版本的门户,则设置此属性会返回错误。

Object
timeOfDay
(可读写)

要用于分析的日期和时间。

可以使用 datetime 对象指定该属性。 例如,要指定路程应从 2022 年 3 月 29 日 5:00 p.m. 开始,请将参数值指定为 datetime.datetime(2022, 3, 29, 17, 0, 0)

可使用以下日期来指定一周中的每一天,而无需使用特定的日期:

  • 今天 - 12/30/1899
  • 星期日 - 12/31/1899
  • 星期一 - 1/1/1900
  • 星期二 - 1/2/1900
  • 星期三 - 1/3/1900
  • 星期四 - 1/4/1900
  • 星期五 - 1/5/1900
  • 星期六 - 1/6/1900

例如,要指定路程从星期二 5:00 p.m. 开始,则请将参数值指定为 datetime.datetime(1900, 1, 2, 17, 0, 0)

默认值为 None,表明分析将为时间中立。

如果分析的出行模式的阻抗属性没有与时间相关的属性(例如交通或公共交通),则该属性将不会产生影响。

了解如何在网络分析中使用和解释日期和时间的详细细腻

DateTime
timeUnits
(可读写)

报告分析输出中的行驶时间时使用的单位。 无论网络数据集中成本属性的单位如何,输出都将转换为使用在此属性中设置的单位并以该单位进行报告。 将返回该属性并将其设置为 TimeUnits 枚举的成员。 默认为 TimeUnits.Minutes

Object
timeZone
(可读写)

指示 timeOfDay 属性中所指定的时间是否解释为输入位置的本地时间或协调世界时间 (UTC)。 将返回该属性并将其设置为 TimeZoneUsage 枚举的成员,且仅在 timeOfDay 属性不为 None 时可用。 默认为 TimeZoneUsage.LocalTimeAtLocations

Object
timeZoneForTimeWindows
(可读写)

指示输入停靠点的时间窗口中所指定的时间是否解释为输入位置的本地时间或协调世界时间 (UTC)。 将返回该属性并将其设置为 TimeZoneUsage 枚举的成员。 默认为 TimeZoneUsage.LocalTimeAtLocations

Object
travelMode
(可读写)

要用于分析的出行模式。

将返回该值并将其设置为 arcpy.nax.TravelMode 对象,但也可以使用出行模式的字符串名称或包含出行模式的有效 JSON 表示的字符串进行设置。 默认为用于分析的网络数据集上定义的默认出行模式。

了解有关出行模式的详细信息

Object

方法概述

方法说明
addFields (input_type, field_description)

将自定义字段添加到指定的输入类。 这些字段将包含在通过 fieldMappings 方法创建的字段映射字典中,也可与 insertCursor 方法配合使用。

count (input_type)

返回为输入类型添加的行数。

fieldMappings (input_type, {use_location_fields}, {list_candidate_fields})

生成将输入类型名称字段映射到 arcpy.nax.NAClassFieldMap 对象的 NAClassFieldMappings 字典,以允许您将字段从输入数据映射到求解程序属性。 字典可以用作 load 方法 field_mappings 参数的输入。

fieldNames (input_type, {use_location_fields})

获取指定输入类型支持的字段名称列表。

insertCursor (input_type, field_names, {append})

在指定的输入类型上建立写入光标。 此游标可用于将行直接添加到输入。

load (input_type, features, {field_mappings}, {append}, {max_features})

设置用于分析的输入要素。

setLocateSettingsOverrides (input_type, {search_sources}, {allow_auto_relocate}, {search_tolerance}, {search_tolerance_units})

为指定输入类设置定位设置,并覆盖为分析指定的默认定位设置。 如果想要使用不同的规则定位不同的输入,这非常有用。 例如,在 OD 成本矩阵分析中,如果搜索查询不需要应用于输入目标和障碍,则可以使用仅应用于输入源的搜索查询。

可使用此方法覆盖指定输入类的 searchSourcesallowAutoRelocatesearchTolerancesearchToleranceUnits 属性值。

了解有关在网络中定位输入的详细信息

solve ()

使用在 Route 对象上设置的属性和已加载的输入执行路径分析。

方法

addFields (input_type, field_description)
参数说明数据类型
input_type

The type of input to which the fields will be added.

应使用 RouteInputDataType 枚举设置此参数。

Object
field_description
[field_description,...]

The fields and their properties that will be added to the input class. The value will be constructed as a list of lists with each row containing the following items:

  • Field name—The name of the field that will be added to the input class.
  • Field type—The type of the new field.
  • Field alias—The alternate display name given to the field name.
  • Field length—The length of the field being added. This sets the maximum number of allowable characters for each record of the field. This option is only applicable to fields of type text. The default length is 255.
  • Default value—The default value of the field.

Available field types are as follows:

Field typeDescription

TEXT

此字段类型将为文本类型。 文本字段支持字符串。

FLOAT

此字段类型将为浮点型。 浮点型字段支持介于 -3.4E38 和 1.2E38 之间的小数。

DOUBLE

此字段类型将为双精度型。 双精度型字段支持介于 -2.2E308 和 1.8E308 之间的小数。

SHORT

此字段类型将为短整型。 短整型字段支持介于 -32,768 和 32,767 之间的整数。

LONG

此字段类型将为长整型。 长整型字段支持介于 -2,147,483,648 和 2,147,483,647 之间的整数。

DATE

此字段类型将为日期类型。 日期字段支持日期和时间值。

GUID

此字段类型将为 GUID。 GUID 字段可存储注册表样式的字符串,该字符串包含用大括号括起来的 36 个字符。

BIGINTEGER

此字段类型将为大整型。 大整型字段支持 -(253) 和 253 之间的整数

TIMEONLY

此字段类型仅限时间。 仅时间字段支持不带日期值的时间值。

DATEONLY

此字段类型仅限日期。 仅日期字段支持不带时间值的日期值。

TIMESTAMPOFFSET

此字段类型将为时间戳偏移。 时间戳偏移字段支持日期、时间和相对于 UTC 值的偏移。

Only the field name and type are required. Use None as a place holder for any of the other parameters to accept the default or if the parameter does not apply to the specified field type.

The method will return an error if the field already exists in the table or if any of the field properties are invalid.

旧版本:
The GUID, BIGINTEGER, TIMEONLY, DATEONLY, and TIMESTAMPOFFSET field types are not supported when the network data source is a portal running ArcGIS Enterprise 11.1.x or earlier.

List
count (input_type)
参数说明数据类型
input_type

用于计数的输入要素类型。

应使用 RouteInputDataType 枚举设置此参数。

Object
返回值
数据类型说明
Integer

行数。

fieldMappings (input_type, {use_location_fields}, {list_candidate_fields})
参数说明数据类型
input_type

The type of input for which the field mappings are returned.

应使用 RouteInputDataType 枚举设置此参数。

See descriptions of the fields available for each input type

Object
use_location_fields

Specifies whether network location fields will be included in the returned field mappings dictionary. Network location fields describe the point on the network where an object is located. You can use network location fields to more precisely control how analysis inputs locate on the network and to save time when calling the solve method because the solver will not have to calculate the location fields from the geometry of the inputs. You can calculate location fields for a feature class using the Calculate Locations tool.

Learn more about network location fields and how inputs are located on the network

When this argument is set to True, the returned field mappings dictionary will contain network location fields. The default is False; the field mapping dictionary will not include network location fields.

(默认值为 False)

Boolean
list_candidate_fields
[list_candidate_fields,...]

Use this parameter to map additional, nondefault fields from the input data to the analysis inputs. For example, if the input feature class contains a field named MyField, and you want it to be included in the analysis inputs, pass the MyField field object to the list_candidate_fields parameter. MyField will be included in the returned field mapping dictionary and automatically mapped. When you call the load method using these field mappings, MyField will be included in the analysis inputs along with all the default fields. In many cases, these extra fields will be passed to the analysis output as well.

Specify this parameter as a list of arcpy.Field objects, which can be obtained from a given feature class or table using the arcpy.ListFields function.

Learn more about best practices for setting up analysis inputs

旧版本:
If the network data source is an ArcGIS Enterprise portal, the method will return an error if any of the fields specified are of a type that is not supported by the portal version.

(默认值为 None)

Field
返回值
数据类型说明
Dictionary

如果 NAClassFieldMappings 字典中的键为字段名称和值,则其为 arcpy.nax.NAClassFieldMap 对象。

fieldNames (input_type, {use_location_fields})
参数说明数据类型
input_type

返回其支持的字段名称的输入类型。

应使用 RouteInputDataType 枚举设置此参数。

See descriptions of the fields available for each input type

Object
use_location_fields

指示网络位置字段是否包含在返回的字段名称列表中。网络位置字段可描述网络中对象所在的点。您可以使用网络位置字段更精确地控制分析输入在网络上的定位方式,并且由于求解程序不必从输入的几何计算位置字段,因此在调用 solve 方法时可以节省时间。您可以使用计算位置工具计算要素类的位置字段。

了解有关网络位置字段以及如何在网络中定位输入的详细信息

当此参数设置为 True 时,返回的字段名称列表将包含网络位置字段。默认为 False;字段名称列表不包括网络位置字段。

(默认值为 False)

Boolean
返回值
数据类型说明
String

指定输入类型支持的字段名称列表。

insertCursor (input_type, field_names, {append})
参数说明数据类型
input_type

The type of input into which the cursor can be used to insert rows.

应使用 RouteInputDataType 枚举设置此参数。

Object
field_names
[field_names,...]

A list of field names of the input type whose values you want to set when inserting rows using the cursor. You can get the names of the fields supported by an input type by using the fieldNames method.

See descriptions of the fields available for each input type

In addition to regular fields, you can also set the geometry of the input using one of the following geometry tokens:

  • SHAPE@XY一组要素的质心 x,y 坐标。
  • SHAPE@XYZ一组要素的质心 x,y,z 坐标。
  • SHAPE@JSON表示几何的 Esri JSON 字符串。
  • SHAPE@WKBOGC 几何的熟知二进制 (WKB) 表示。 用于以可移植的方式将几何值表示为连续的字节流。
  • SHAPE@WKTOGC 几何的熟知文本 (WKT) 表示。 用于以可移植的方式将几何值表示为文本字符串。
  • SHAPE@要素的几何对象。

The SHAPE@XY and SHAPE@XYZ tokens are only supported for point-based input types. When using the SHAPE@XY and SHAPE@XYZ tokens, the x-, y-, and z-values should be specified in the spatial reference of the network data source being used in the analysis.

String
append

Specifies whether the features being inserted should be appended to the existing set of features for the input type. A value of True indicates that the new features should be appended; the existing features will be preserved. This is the default. A value of False indicates that any existing features for the input type should be deleted and replaced with the features currently being inserted.

(默认值为 True)

Boolean
返回值
数据类型说明
Object

可用于写入要素的 SolverInsertCursor 对象。

load (input_type, features, {field_mappings}, {append}, {max_features})
参数说明数据类型
input_type

The type of input feature to load.

应使用 RouteInputDataType 枚举设置此参数。

Object
features

The input features to load. This parameter accepts the following input types:

  • Catalog path to a feature class or a table
  • Layer object
  • String representing the name of a layer
  • FeatureSet or RecordSet object

For layer inputs, only selected features will be loaded. If a layer has a definition query, only the subset of features visible with the definition query will be loaded. The method also honors the Extent geoprocessing environment; only features in the specified extent will be loaded.

String
field_mappings

An NAClassFieldMappings dictionary that maps the field names of the input type to arcpy.nax.NAClassFieldMap objects representing the mapping of fields from the input features. Valid input for this parameter can be constructed using the fieldMappings method.

If field mappings are not specified, all fields from the input features that have the same name as the supported fields for the input type will be mapped.

See descriptions of the fields available for each input type

(默认值为 None)

Dictionary
append

Indicates whether the features being loaded should be appended to the existing set of features for the input type. A value of True indicates that the new features should be appended; the existing features will be preserved. This is useful if you want to load inputs from multiple feature classes or tables to use in a single analysis. This is the default. A value of False indicates that any existing features for the input type should be deleted and replaced with the features currently being loaded.

(默认值为 True)

Boolean
max_features

The maximum number of features that can be loaded into the input type. This is useful if you are creating a tool or service and want an error returned if the size of the input exceeds the available resources. The load method will return an arcpy.nax.LimitError if the number of input features exceeds the max_features limit.

If a value is not specified, no limit is enforced for the count of the input features.

(默认值为 None)

Integer
setLocateSettingsOverrides (input_type, {search_sources}, {allow_auto_relocate}, {search_tolerance}, {search_tolerance_units})
参数说明数据类型
input_type

The type of input for which to override default locate settings.

应使用 RouteInputDataType 枚举设置此参数。

Object
search_sources
[[Source, Expression],...]

The list of network sources to be used when locating inputs of the designated type on the network, and, optionally, a query to restrict the search to a subset of the features within a source feature class.

See the documentation for the searchSources property for examples of proper syntax for this parameter.

Specifying a value for this parameter overrides the default searchSources property value for the designated input type.

If this parameter is not specified or is set to None, the searchSources value will be used for this input type.

The method returns an error if this parameter is used and the network data source is ArcGIS Online.

String
allow_auto_relocate

Specifies whether inputs of the designated type with existing network location fields can be automatically relocated at solve time to ensure valid, routable location fields for the analysis. If the value is True, points located on restricted network elements and points affected by barriers will be relocated to the closest routable location. If the value is False, network location fields will be used as is, even if the points are unreachable, and this may cause the solve to fail.

Even if the value is False, inputs with no location fields or incomplete location fields will be located at solve time.

Specifying a value for this parameter overrides the default allowAutoRelocate property value for the designated input type.

If this parameter is not specified or is set to None, the allowAutoRelocate value will be used for this input type.

The method returns an error if the network data source is ArcGIS Online.

The method returns an error if the network data source is an ArcGIS Enterprise portal that does not support using network location fields.

Boolean
search_tolerance

The maximum search distance to use when locating inputs of the designated type on the network.

Specifying a value for this parameter overrides the default searchTolerance property value for the designated input type.

If this parameter is not specified or is set to None, the searchTolerance value will be used for this input type.

The units of this parameter value are set using the search_tolerance_units parameter; however, if no value is set for that parameter, the search_tolerance value will be interpreted in the units specified in the searchToleranceUnits property.

This parameter does not apply to line and polygon barriers; the method will return an error if this parameter is specified when the input_type value is one of these barrier types.

Double
search_tolerance_units

The units of the maximum search distance when locating inputs of the designated type of the network. The parameter is specified using a member of the DistanceUnits enumeration.

Specifying a value for this parameter overrides the default searchToleranceUnits property value for the designated input type.

If this parameter is not specified or is set to None, the searchToleranceUnits will be used for this input type.

The value specified using the search_tolerance parameter is interpreted using these units. If that parameter is not specified, the value of the searchTolerance property will be interpreted using these units for the designated input type only.

This parameter does not apply to line and polygon barriers; the method will return an error if this parameter is specified when the input_type value is one of these barrier types.

Double
solve ()
返回值
数据类型说明
Object

arcpy.nax.RouteResult 对象可用于访问输出和求解程序消息。

代码示例

路线示例

使用输入停靠点的要素类执行路径分析。

# An example showing how to perform route analysis using a feature class for input stops.
import arcpy
arcpy.CheckOutExtension("network")

nds = "C:/data/NorthAmerica.gdb/Routing/Routing_ND"
nd_layer_name = "Routing_ND"
input_stops = "C:/data/io.gdb/Stops"
output_routes = "C:/data/io.gdb/Routes"

# Create a network dataset layer and get the desired travel mode for analysis
arcpy.nax.MakeNetworkDatasetLayer(nds, nd_layer_name)
nd_travel_modes = arcpy.nax.GetTravelModes(nd_layer_name)
travel_mode = nd_travel_modes["Driving Time"]

# Instantiate a Route solver object
route = arcpy.nax.Route(nd_layer_name)
# Set properties
route.timeUnits = arcpy.nax.TimeUnits.Minutes
route.travelMode = travel_mode
route.routeShapeType = arcpy.nax.RouteShapeType.TrueShapeWithMeasures
# Load inputs
route.load(arcpy.nax.RouteInputDataType.Stops, input_stops)
# Solve the analysis
result = route.solve()

# Export the results to a feature class
if result.solveSucceeded:
    result.export(arcpy.nax.RouteOutputDataType.Routes, output_routes)
else:
    print("Solved failed")
    print(result.solverMessages(arcpy.nax.MessageSeverity.All))