Input and output data types

When you perform network analysis using the arcpy.nax module, you need to work with feature classes and tables that store the inputs and outputs of a network analysis. Each analysis has one or more types of feature classes and tables that are referenced in the arcpy.nax documentation as data types.

The arcpy.nax module has input and output data types that are specific to each analysis. You specify the input data type when loading the inputs using the load or insertCursor method. For example. to load the stops used in a route analysis, you use the load method on the Route object and specify the input data type as arcpy.nax.RouteInputDataType.Stops. After the analysis is executed, you'll specify the output data type to retrieve the results using the export or searchCursor method. For example, to export the routes created by the route analysis, use the export method on the RouteResult object and specify the output data type as arcpy.nax.RouteOutputDataType.Routes.

The following code snippet shows how to load stops into a route analysis and export the output routes after the analysis has been executed:

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"

arcpy.nax.MakeNetworkDatasetLayer(nds, nd_layer_name)
route = arcpy.nax.Route(nd_layer_name)
route.load(arcpy.nax.RouteInputDataType.Stops, input_stops)
result = route.solve()
result.export(arcpy.nax.RouteOutputDataType.Routes, output_routes)

To effectively use the input and output data types, you should understand the fields supported by each data type. The fields on the input data types allow you to specify various settings that can influence the analysis results. For example, RouteInputDataType.Stops supports a RouteName field. This field allows you to assign stops to routes and provides a way to create multiple routes in a single analysis. The fields on the output data types contains attributes that describe the analysis results. For example, RouteOutputDataType.Routes supports a Total_Minutes field that provides the total travel time for the route in minutes.

Conseil :

The fieldNames method on the analysis object can be used to get a list of fields supported by an input data type. The result object also has a fieldNames method that can be used to get a list of fields supported by an output data type.

The other help topics in this category provide descriptions of the fields supported by the various data types.