OriginDestinationCostMatrixResult

摘要

包含起点 - 目的地成本矩阵分析结果的对象,可用于访问输出和求解程序消息。

说明

无法直接创建此类的实例。 相反,它们由 OriginDestinationCostMatrix 类的 solve 方法返回。

了解有关如何使用结果对象来访问和使用分析输出的详细信息

属性

属性说明数据类型
isPartialSolution
(只读)

如果求解程序产生了部分解决方案,则将返回 True,这意味着并非所有输入都包含在结果中。 如果其中一个输入未定位并且求解程序类的 ignoreInvalidLocations 属性被设置为 True,则会发生这种情况。

Boolean
solveSucceeded
(只读)

如果求解程序成功执行,则将返回 True

Boolean
spatialReference
(只读)

返回输出要素的空间参考。 例如,通过 export 方法创建的要素类和从 searchCursor 方法检索的几何对象将具有此空间参考。 通常,spatialReference 值为分析中所用的网络数据集或服务的空间参考。

SpatialReference

方法概述

方法说明
count (output_type)

返回输出类型的行数。

export (output_type, output_features)

将分析结果导出到要素类或表。

输出要素将在用于分析的网络数据集的空间参考中创建。如果已设置 arcpy.env.outputCoordinateSystem 环境,则将使用指定的坐标系创建输出要素。

extent ({output_type})

返回分析输出的范围。

如果分析求解失败,此方法将返回 RuntimeError 异常。

fieldNames (output_type)

返回指定输出类型支持的字段名称列表。

saveAsLayerFile (file_name)

将分析结果和设置保存到图层文件或图层包。 可以在 ArcGIS Pro 中将图层文件或包作为分析设置记录打开或用于可视化结果。 也可以在 ArcGIS Desktop 中打开图层文件。

如果求解程序对象上的 allowSaveLayerFile 属性设置为 False,该方法将返回 RuntimeError 异常。

旧版本:

基于运行 10.9 之前版本 ArcGIS Enterprise 的门户的路径服务不支持保存图层包。 在这种情况下,该方法将返回 RuntimeError 异常。

searchCursor (output_type, field_names, {where_clause})

在指定的输出类型上建立搜索光标。 此游标可用于直接从输出读取行。

solverMessages (severity)

获取求解程序返回的错误、警告和信息性消息。

toArrowTable (output_type, field_names, {file_name}, {max_batch_size})

Apache Arrow 格式返回 OD 成本矩阵结果。

注:

如果求解器对象使用服务 URL 作为其网络数据源,Arrow 输出不可用。 在这种情况下,该方法将返回 RuntimeError 异常。

方法

count (output_type)
参数说明数据类型
output_type

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

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

Object
返回值
数据类型说明
Integer

行数。

不引发任何异常。

export (output_type, output_features)
参数说明数据类型
output_type

要导出的输出类型。

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

See descriptions of the fields included in each output type

Object
output_features

包含导出要素的输出要素类或表的目录路径。

String
extent ({output_type})
参数说明数据类型
output_type

The type of output features for which to get the extent.

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

If you do not specify a value, or you specify a value of None, the extent for the combined analysis outputs is returned.

Object
返回值
数据类型说明
Extent

arcpy.Extent 对象用于指示指定输出类型的范围。

fieldNames (output_type)
参数说明数据类型
output_type

要返回其字段名称列表的输出类型。

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

See descriptions of the fields included in each output type

Object
返回值
数据类型说明
String

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

saveAsLayerFile (file_name)
参数说明数据类型
file_name

The catalog path of the output layer file (.lyr) or layer package (.lpkx) to write.

警告:

Layer files with an .lyr extension cannot be saved if the solver object uses a service URL as its network data source. The method returns a RuntimeError exception in this case.

String
searchCursor (output_type, field_names, {where_clause})
参数说明数据类型
output_type

The type of output that will be read.

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

Object
field_names
[field_names,...]

A list of field names of the output type whose values will be returned by the cursor. You can get the names of the fields that are supported by an output type using the fieldNames method.

See descriptions of the fields included in each output type

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

  • SHAPE@XYA tuple of the feature's centroid's x- and y-coordinates.
  • SHAPE@XYZA tuple of the feature's centroid's x-, y-, and z-coordinates.
  • SHAPE@JSON The Esri JSON string representing the geometry.
  • SHAPE@WKBThe well-known binary (WKB) representation for OGC geometry. It provides a portable representation of a geometry value as a contiguous stream of bytes.
  • SHAPE@WKTThe well-known text (WKT) representation for OGC geometry. It provides a portable representation of a geometry value as a text string.
  • SHAPE@A geometry object for the feature.

The SHAPE@XY and SHAPE@XYZ tokens are only supported for point-based output types. The x-, y-, and z-values returned when using the SHAPE@XY and SHAPE@XYZ tokens are in the spatial reference reported by the solver result object's spatialReference property, and this is typically the same as the spatial reference of the network data source used for the analysis.

提示:

Retrieving geometry for the Lines output type can be slow. For best performance, do not request geometry using any of the geometry tokens.

String
where_clause

用于限制所返回的记录的可选表达式。 有关 WHERE 子句和 SQL 语句的详细信息,请参阅在 ArcGIS 中使用的查询表达式的 SQL 参考

(默认值为 None)

String
返回值
数据类型说明
Object

从输出读取行的 SolverResultSearchCursor 对象。

solverMessages (severity)
参数说明数据类型
severity

要返回的消息类型。

应使用 MessageSeverity 枚举指定此参数。

Object
返回值
数据类型说明
List

返回的消息为由 列表组成的列表。内部列表包含两个值;第一个值为表示消息代码的数字,第二个值为消息文本。

从失败的起点 - 目的地成本矩阵分析返回的消息列表的示例。

[[-2147200995, '0 location(s) in "Destinations" are valid.  Need at least 1 valid location(s).'],
 [30024, 'Solve returned a failure.'],
 [-2147200995, 'Insufficient number of valid locations in "Origins" or "Destinations".']]

toArrowTable (output_type, field_names, {file_name}, {max_batch_size})
参数说明数据类型
output_type

The type of output that will be read.

使用 OriginDestinationCostMatrixOutputDataType 枚举设置此参数。

警告:

Only the Lines output type is currently supported. The method returns a RuntimeError exception if a different output type is specified.

Object
field_names
[field_names,...]

A list of field names of the output type to include in the Arrow table.

See descriptions of the fields included in each output type

警告:

For the Lines output type, the Shape, OriginName, and DestinationName fields are not supported.

String
file_name

The file path to use to save the analysis results permanently. The file will contain one or more Arrow record batches and can be opened in any package or library that supports the Arrow format.

This parameter is optional. If it is not specified, the Arrow table returned by the method can be used within the current Python operation but will not be stored permanently.

String
max_batch_size

The maximum number of records to include in a single record batch in the output Arrow table. When no value or None is specified, a value of 2,147,483,647 is used. If the total number of records is smaller than the specified max_batch_size, the output Arrow table and file will contain only one record batch.

For very large analyses, writing the output in batches prevents out-of-memory errors. The method always returns a single Arrow table and output file (if the file_name parameter is specified), but the presence of multiple record batches in the output may influence how you handle it in subsequent code. When an Arrow table or file containing multiple record batches is converted to another format, such as a Pandas DataFrame, you may not be able to do a zero-copy read of the entire table or file. In a zero-copy read, the data can be accessed without additional serialization overhead to load it in RAM. To achieve this zero-copy read behavior, your code may need to handle one record batch at a time.

For the Lines output type, for most applications, it is important to keep all records associated with the same origin together in the same batch. This ensures that you can do a zero-copy read of all records for that origin for post-processing or further analysis. If the number of records associated with a given origin exceeds the specified max_batch_size, the method will override the max_batch_size value, and the resulting record batches will increase to the minimum size needed to store all records associated with the origin.

The value for max_batch_size cannot exceed 2,147,483,647.

Integer
返回值
数据类型说明
Object

Apache ArrowPython 对象表示指定字段所需的输出类型。