Skip To Content

RouteResult

Summary

An object containing the results of a route analysis that can be used to access outputs and solver messages.

Discussion

Instances of this class cannot be created directly. Instead, they are returned by the solve method of the Route class.

Properties

PropertyExplanationData Type
isPartialSolution
(Read Only)

Returns True if the solver produced a partial solution, meaning that not all inputs were included in the results. This can occur if one of the inputs is unlocated and the solver class's ignoreInvalidLocations property is set to True.

Boolean
solveSucceeded
(Read Only)

Returns True if the solve was successful.

Boolean

Method Overview

MethodExplanation
export (output_type, output_features)

The output features will be created in the spatial reference of the network dataset used for the analysis. If the arcpy.env.outputCoordinateSystem environment is set, the output features will be created with the specified coordinate system instead.

Exports the analysis results to a feature class or table.

fieldNames (output_type)

Returns a list of field names supported by a specified output type.

saveAsLayerFile (file_name)

Save the analysis result and settings to a layer file. The layer file can be opened in ArcGIS Desktop or ArcGIS Pro as a record of the analysis settings or to visualize the results.

saveRouteData (file_name)

Save the outputs from the analysis to a ZIP file. The ZIP file can be used to share the routes from the analysis as route layer items in ArcGIS Online or ArcGIS Enterprise using the Share As Route Layers tool.

A route layer item can be used by various applications, such as Navigator for ArcGIS to provide route guidance for field workers, the Directions pane in Map Viewer to further customize the route contained in the route layer, or ArcGIS Pro to create a new route analysis layer from a route layer.

The output features will be created in the spatial reference of the network dataset used for analysis. If the arcpy.env.outputCoordinateSystem environment has been set, the output will be created in that spatial reference instead.

If the solve fails, saveRouteData returns a RuntimeError exception.

searchCursor (output_type, field_names, {where_clause})

Establishes a search cursor on the specified output type. This cursor can be used to read rows directly from the output.

solverMessages (severity)

Get error, warning, and informational messages returned by the solver.

Methods

export (output_type, output_features)
ParameterExplanationData Type
output_type

The type of output to export.

The parameter should be set using the RouteOutputDataType enumeration.

Object
output_features

The catalog path to the output feature class or table that will contain the exported features.

String
fieldNames (output_type)
ParameterExplanationData Type
output_type

The type of output for which to return a list of field names.

The parameter should be set using the RouteOutputDataType enumeration.

Object
Return Value
Data TypeExplanation
String

A list of field names supported by the specified output type.

saveAsLayerFile (file_name)
ParameterExplanationData Type
file_name

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

String
saveRouteData (file_name)
ParameterExplanationData Type
file_name

The full path of the output ZIP file.

String
searchCursor (output_type, field_names, {where_clause})
ParameterExplanationData Type
output_type

The type of output to read.

The parameter should be set using the RouteOutputDataType enumeration.

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. 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 x,y coordinates.
  • SHAPE@XYZ
  • 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.

String
where_clause

An optional expression that limits the records returned. For more information on WHERE clauses and SQL statements, see SQL reference for elements used in query expressions.

(The default value is None)

String
Return Value
Data TypeExplanation
Object

A SolverResultSearchCursor object that reads rows from the output.

solverMessages (severity)
ParameterExplanationData Type
severity

The type of messages to be returned.

The parameter should be specified using the MessageSeverity enumeration.

Object
Return Value
Data TypeExplanation
List

The messages are returned as a list of lists. The inner list contains two values; the first is a number representing the message code, and the second value is the message text.

An example of a list of messages returned from a failed origin destination cost matrix analysis.

[[-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".']]