OriginDestinationCostMatrixResult

Краткая информация

Объект с результатами анализа матрицы Источник-Назначение, который можно использовать для доступа к выходным данным и сообщениям механизма расчета.

Обсуждение

Экземпляры этого класса нельзя создавать напрямую. Но они возвращаются методом solve класса OriginDestinationCostMatrix.

Более подробно о том, как использовать объект результата для доступа и работы с результатами анализа.

Свойства

СвойствоОписаниеТип данных
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.

Это метод возвращает исключение RuntimeError, если свойство allowSaveLayerFile объекта-механизма расчета задан как False.

Прежние версии:

Маршрутизация сервисов на основе портала с версией ArcGIS Enterprise старше, чем 10.9 не поддерживает сохранение пакетов слоя. Этот метод возвращает исключение RuntimeError, если это именно этот случай.

searchCursor (output_type, field_names, {where_clause})

Задает курсор поиска для заданного типа выходных данных. Этот курсор предназначен для считывания строк непосредственно из выходных данных.

solverMessages (severity)

Получает сообщения об ошибках, предупреждениях и информационные сообщения, возвращаемые механизмом расчета.

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

Возвращает результат Матрицы Источник-Назначение в формате Apache Arrow.

Примечание:

Выходные данные Arrow недоступны, если объект механизма расчета использует URL сервиса в качестве сетевого источника данных. В этом случае метод возвращает исключение 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 to read.

Параметр должен быть задан с помощью перечисления OriginDestinationCostMatrixOutputDataType.

Object
field_names
[field_names,...]

A list of field names of the output type whose values the cursor will return. 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 см. в разделе Справочник по SQL для выражений запросов, применяемых в ArcGIS.

(Значение по умолчанию — 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 to 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, all records will be written to the same record batch, and 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.

Integer
Возвращаемое значение
Тип данныхОписание
Object

Объект Python таблицы Apache Arrow, содержащий желаемый тип выходных данных с указанными полями.