The Network Analyst module arcpy.na is a Python module for working with network analysis functionality provided with the ArcGIS Network Analyst extension. It provides access to all the geoprocessing tools available in the Network Analyst toolbox as well as other helper functions and classes that allow you to automate Network Analyst workflow through Python.
To accomplish your workflow, you will most likely use functions and classes from ArcPy or other modules such as the arcpy.mapping module. In particular, the ArcPy Describe function can be used to access read-only properties for a network dataset or a Network Analyst layer.
Network Analyst functions
Adds a field to a sublayer of a network analysis layer.
Adds network analysis objects to a network analysis layer. The objects are added to specific sublayers such as Stops and Barriers. Objects are input as features or records.
Reconstructs the network connectivity and attribute information of a network dataset. The network dataset needs to be rebuilt after making edits to the attributes or the features of a participating source feature class. After the source features are edited, the tool establishes the network connectivity only in the areas that have been edited to speed up the build process; however, when the network attributes are edited, the entire extent of the network dataset is rebuilt. This may be a slow operation on a large network dataset.
Adds fields to the input features that contain the network location of the features. The tool is used to store the network location information as feature attributes to quickly load the features as inputs for a network analysis layer.
Returns a Boolean indicating whether the number of edge source features from the specified network dataset that are intersected by the features within the specified feature layer is less than or equal to the specified cutoff. The function is useful to restrict the number of features that can be loaded as line or polygon barriers into a network analysis layer.
Creates two feature classes and a table, which together contain information about the edges, junctions, and turns that are traversed while solving a network analysis layer.
Creates a new turn feature class to store turn features that model turning movements in a network dataset.
Generates turn-by-turn directions from a network analysis layer with routes. The directions can be written to a file in text, XML, or HTML format. If you provide an appropriate stylesheet, the directions can be written to any other file format.
Creates a network dataset that minimizes the number of line features required to correctly model the input network dataset. The more efficient output network dataset reduces the time required to solve analyses, draw results, and generate driving directions. This tool outputs a new network dataset and source feature classes; the input network dataset and its source features remain unchanged.
Finds one or more facilities closest to an incident based on travel time, distance, or other cost and outputs the best route, chosen facility, and driving directions between the incident and the facility. For example, you can use this tool to find the closest hospital to an accident, the closest police cars to a crime scene, or the closest store to a customer's address.
Finding a route analysis can mean determining the quickest or shortest way to travel between locations. You might want to use this tool to generate driving directions to visit multiple stops or to measure the distance or travel time between locations. The tool is capable of finding routes for one or more vehicles each time it runs, so you can determine the best routes for several drivers to visit preassigned stops, for instance, or measure in a single solve the distance of home-to-work trips for many commuters.
Creates a feature class of route lines on the map and corresponding text directions generated by solving a network analysis layer. The output can be modified using the StreetDirectionProperties object of the network analysis layer.
Creates an origin-destination (OD) cost matrix from multiple origins to multiple destinations. An OD cost matrix is a table that contains the travel time and travel distance from each origin to each destination. Additionally, it ranks the destinations that each origin connects to in ascending order based on the minimum time or distance required to travel from that origin to each destination. The best path on the street network is discovered for each origin-destination pair, and the travel times and travel distances are stored as attributes of the output lines. Even though the lines are straight for performance reasons, they always store the travel time and travel distance along the street network, not straight-line distance.
Creates a service area network analysis layer, sets the analysis properties, and solves the analysis. This tool is ideal for setting up a service area geoprocessing service on the web. A network service area is a region that encompasses all streets that can be accessed within a given distance or travel time from one or more facilities.
Returns a dictionary of network analysis class names from the network analysis layer specified as argument. The dictionary keys are the network analysis class names, and the values are the layer names that reference the network analysis classes from the network analysis layer. The layer names are used as input in some geoprocessing tools such as Add Locations and Add Field To Analysis Layer.
Returns a Network Analyst solver properties object based on the type of the network analysis layer specified as the argument. The solver properties object is used to update the analysis properties for the layer.
Returns a dictionary of travel mode objects that are available with the network dataset. The dictionary keys are the names of the travel modes and the dictionary values are the travel mode objects. The travel mode objects can be used to update a solver properties object (RouteSolverProperties, ClosestFacilitySolverProperties, ServiceAreaSolverProperties, ODCostMatrixSolverProperties, VehicleRoutingProblemSolverProperties, or LocationAllocationSolverProperties) before solving a particular analysis.
Increases the maximum number of edges per turn in a turn feature class.
Returns a list of the languages in which you can generate directions for the routes you create during network analysis. The list of available languages depends on which directions language packs you have installed on your machine.
Returns a list of the available styles for generating directions from a route created during network analysis. Each directions style is appropriate for a different application.
Makes a closest facility network analysis layer and sets its analysis properties. A closest facility analysis layer is useful in determining the closest facility or facilities to an incident based on a specified network cost.
Makes a location-allocation network analysis layer and sets its analysis properties. A location-allocation analysis layer is useful for choosing a given number of facilities from a set of potential locations such that a demand will be allocated to facilities in an optimal and efficient manner.
Makes an origin–destination (OD) cost matrix network analysis layer and sets its analysis properties. An OD cost matrix analysis layer is useful for representing a matrix of costs going from a set of origin locations to a set of destination locations.
Makes a route network analysis layer and sets its analysis properties. A route analysis layer is useful for determining the best route between a set of network locations based on a specified network cost.
Makes a service area network analysis layer and sets its analysis properties. A service area analysis layer is useful in determining the area of accessibility within a given cutoff cost from a facility location.
Makes a vehicle routing problem (VRP) network analysis layer and sets its analysis properties. A vehicle routing problem analysis layer is useful for optimizing a set of routes using a fleet of vehicles.
Creates and populates additional fields on the turn feature classes that reference the edges by alternate IDs. The alternate IDs allow for another set of IDs that can help maintain the integrity of the turn features in case the source edges are being edited.
Solves the network analysis layer problem based on its network locations and properties.
The Solve Location-Allocation tool chooses the best locations from a set of input locations.
Creates a vehicle routing problem (VRP) network analysis layer, sets the analysis properties, and solves the analysis, which is ideal for setting up a VRP web service. A vehicle routing problem analysis layer finds the best routes for a fleet of vehicles.
Converts an ArcView turn table or ArcInfo Workstation coverage turn table to an ArcGIS turn feature class.
Updates the network attribute parameter value for a network analysis layer. The tool should be used to update the value of an attribute parameter for a network analysis layer prior to solving with the Solve tool. This ensures that the solve operation uses the specified value of the attribute parameter to produce appropriate results.
Updates all the edge references in turn feature classes using an alternate ID field. This tool should be used after making edits to the input line features that are referenced by the turn features to synchronize the turn features based on the alternate ID fields.
Updates all the edge references in the turn feature class using the geometry of the turn features. This tool is useful when the IDs listed for the turn can no longer find the edges participating in the turn due to edits to the underlying edges.
Downloads live traffic data from a web service and stores it in a dynamic traffic format (DTF) file, which is a file that network datasets can read for live-traffic analysis and display.
Creates a point feature class containing live traffic-incident data from a web service. Traffic incidents include events such as accidents and road construction.
Upgrades the schema of the network dataset. Upgrading the network dataset allows the network dataset to make use of the new functionality available in the current software release.
Network Analyst classes
Provides access to analysis properties from a closest facility network analysis layer. The GetSolverProperties function is used to obtain a ClosestFacilitySolverProperties object from a closest facility network analysis layer.
Provides access to analysis properties from a location-allocation network analysis layer. The GetSolverProperties function is used to obtain a LocationAllocationSolverProperties object from a location-allocation network analysis layer.
Provides the ability to map field names or set default values for the properties of a network analysis class within a network analysis layer. The properties of the network analysis class are used as inputs by the solvers while performing the network analyses.
Provides a Python dictionary of NAClassFieldMap objects that are used to map field names or set default values for the properties of a network analysis class within a network analysis layer. The dictionary keys are the network analysis class property names, and the values are the NAClassFieldMap objects.
Provides access to analysis properties from an origin-destination (OD) cost matrix network analysis layer. The GetSolverProperties function is used to obtain an ODCostMatrixSolverProperties object from an OD cost matrix network analysis layer.
Provides access to analysis properties from a route network analysis layer. The GetSolverProperties function is used to obtain a RouteSolverProperties object from a route network analysis layer.
Provides access to analysis properties from a service area network analysis layer. The GetSolverProperties function is used to obtain a ServiceAreaSolverProperties object from a service area network analysis layer.
Provides read and write access to street directions properties, allowing you to customize the directions output from your network analysis layers. The StreetDirectionsProperties can be read from and set on a SolverProperties object obtained through the GetSolverProperties function.
Provides access to analysis properties from a vehicle routing problem Network Analyst layer. The GetSolverProperties function is used to obtain a VehicleRoutingProblemSolverProperties object from a vehicle routing problem Network Analyst layer.