This document is archived and information here might be outdated.  Recommended version.


Programming with the ArcGIS Network Analyst extension (ArcObjects .NET 10.4 SDK)

Programming with the ArcGIS Network Analyst extension


Summary
This topic discusses the best approach to perform some specific network analysis tasks.

In this topic


Setting goals

The ArcGIS Network Analyst extension can be used in ArcMap through geoprocessing tools, via ArcGIS for Server, or via ArcObjects. Before you begin programming with the ArcGIS Network Analyst extension, determine what your goals are and decide where in the suite of ArcGIS Network Analyst extension products you can best accomplish your goals. Review this topic to help determine how to approach these specific tasks.

Automating ArcGIS Network Analyst extension workflows

See the following references for more information on automating ArcGIS Network Analyst extension workflows:
  • Geoprocessing—Automate your workflow by utilizing the ArcGIS Network Analyst extension geoprocessing tools.
  • Server—For information on how to develop with each of the server application programming interfaces (APIs), see the section on Using the ArcGIS Network Analyst extension in ArcGIS for Server. For information on ArcGIS Network Analyst extension Server ArcObjects, see the following:
    • esriNetworkAnalyst—The server portion of the NetworkAnalyst library to access the public API for the ArcGIS Server API for ArcGIS Network Analyst extension.
  • ArcObjects—For information about programming against the ArcGIS Network Analyst extension API and specific components, see the NetworkAnalyst library overview. For ArcGIS Network Analyst extension ArcObjects information, see the following:
    • esriNetworkAnalyst—See the previously mentioned ArcGIS Network Analyst extension library overview to access the public API for ArcGIS Network Analyst extension solvers, NAClasses, NALayers, street direction agents, locators, and so on. The ArcGIS Server API for the ArcGIS Network Analyst extension is also located in this library.
    • esriNetworkAnalystUI—See the NetworkAnalystUI library overview to understand how to access the ArcGIS Network Analyst extension user interface (UI) in ArcMap.
    • esriGeodatabase—See the Geodatabase library overview to find out how to programmatically access the network dataset.
    • esriNetworkAnalysis—This library is not used by the ArcGIS Network Analyst extension. It contains components to use with the geometric networks used in utility and natural resource networks.

Performing network analysis

See the following for information on finding the shortest path route or closest facility, calculating a service area or origin destination cost matrix, optimizing the routing of a fleet of vehicles, or finding the best location for a facility:
  • ArcMap—To accomplish these tasks use the ArcGIS Network Analyst extension solvers Route, Closest Facility, Service Area, Origin-Destination Cost Matrix, Vehicle Routing Problem (VRP) Solver, or Location-Allocation Solver to analyze a street network with ArcMap. See Types of network analyses to explore conceptual information about each solver.
  • Geoprocessing—To automate your work, use the geoprocessing tools applicable to each of the solvers.
  • ArcObjects—You can also program against the previously mentioned ArcGIS Network Analyst extension library overview within ArcObjects to create a stand-alone application.

Extending the ArcMap user interface

See the following information about working with the ArcGIS Network Analyst extension UI:
  • ArcObjects—To programmatically access components such as the NAWindow and the ArcGIS Network Analyst extension, see the previously mentioned ArcGIS Network Analyst extension UI library overview, which contains helpful information, as well as code snippets.
  • Adding buttons to the NAWindow Context menu—See the sample, Export any network analysis class to a text file, to add a button to the right-click context menu for a class in the NAWindow.

Writing a new solver into the ArcGIS Network Analyst extension framework

If a network solver is required that is not supported, see the following information:
  • ArcObjects—Use C++ to create a solver. The large number of calls to the network dataset via the .NET interop can generate a significant performance hit. The Connectivity Solver sample in the C++ software development kit (SDK) is a good resource to write your solver. For code concerning the use of the network dataset API in writing your solver algorithm, see How to programmatically traverse a street network. For information about programming against the ArcGIS Network Analyst extension API, see the ArcGIS Network Analyst extension library overview.

Working with network datasets

See the following information about working with street networks in ArcGIS:

Working with geometric networks

See the following information about working with utility and natural resource networks in ArcGIS:
  • General concepts—The ArcGIS Network Analyst extension does not work with the directed flow networks necessary to model utility and natural resource networks. See the section on geometric networks in the previously mentioned Geodatabase library overview.

Determine the proximity from one location to another

See the following information about proximity:
  • Geoprocessing—The ArcGIS Network Analyst extension can help you find the network distance between locations. For non-network spatial distances, straight line (Euclidian) distance between two points can be determined by using the Point Distance Geoprocessing tool. Straight line closest facility analysis can be done using the Near Geoprocessing tool. A buffer polygon, instead of network service areas, can be determined using the Buffer and Multiple Ring Buffer tools. A cost table, instead of the origin-destination cost matrix, can be calculated with the Generate Near Table tool.

    See the following table with links to specific geoprocessing tools:
Proximity task
Network distances
Straight line distances
Point-to-Point proximity
Find the nearest location from a set of locations
Find the distance out from a location
Find the distances from every location in a set of locations to every location in another set of locations

Working with street directions

After a network analysis is performed, a list of directions can be generated. See the following information about working with directions:

Extending the network dataset through custom evaluators

An evaluator assigns value for network attributes. See the following information about working with network evaluators:

Loading data into a network analysis layer

See the following information about loading data into network analysis scenarios:

Working with the results of a completed analysis

See the following information about working with network analysis layers after a solve has been completed:
  • General concepts—To understand the resulting output classes after a solve, see the previously listed conceptual help sections for each solver.
  • ArcObjects:

Using the ArcGIS Network Analyst extension in ArcGIS for Server

See the following information about working with the ArcGIS Network Analyst extension in Server:
  • Publishing a network analysis service—See the Server Help system for more information about network analysis services, including a tutorial on publishing the service.
  • Performing network analysis in ArcGIS for Server—There are two main ways to use remote network analysis: through the REST and SOAP APIs.

REST

Routing, Closest Facility, and Service Area solvers are accessible through set Representational State Transfer (REST) endpoints located at http://<server>:6080/arcgis/rest/services.
The general pattern when working with network analysis through REST is as follows:
  1. Set properties that are different from the default.
  2. Set network locations.
  3. Make an Hypertext Transfer Protocol (HTTP) request to the /Solve endpoint.
  4. Use the returned JavaScript Object Notation (JSON) object to get the results of the analysis.
More details can be found in the REST API Help.

REST and Web APIs

If you're writing a light-weight Web application, you do not have to code against the NAServer REST endpoint from scratch. Instead, you can use the out-of-the-box client side libraries. For more information, see the following:

SOAP

Routing, Closest Facility, Service Area, Location-Allocation, Vehicle Routing Problem, and Origin-Destination Const Matrix solvers are accessible through a set of coarse grained stateless Simple Object Access Protocol (SOAP) objects.
The NAServer object is a MapServer server object extension (SOE) that is capable of performing network analysis through a single, stateless method call. It is used in conjunction with various NAServerSolverParams and NAServerSolverResults objects.
The general pattern when working with server objects is as follows:
  1. Get a reference to an NAServer object either through a MapServer that has an NAServer extension loaded or through an NAServer Web service.
  2. Call NAServer.GetSolverParameters2 to get the NAServerSolverParams object holding the default parameters.
  3. Set properties on the NAServerSolverParams object to configure how you want the analysis to be performed.
  4. Set network locations (for example, stops) to use in the analysis.
  5. Call NAServer.Solve, passing in the NAServerSolverParams object.
  6. Use the returned NAServerSolverResults object to get the results of the analysis.
See the SOAP SDK Help topics for more information. 


See Also:

What is the ArcGIS Network Analyst extension?
About the ArcGIS Network Analyst extension tutorial
Essential ArcGIS Network Analyst extension vocabulary
NetworkAnalyst
ArcGIS Network Analyst extension Object Model Diagram
NetworkAnalystUI
An overview of the Network Analyst toolbox
What is a network dataset?
What are geometric networks?