Perhaps you've used a web application that gives you directions between one point and another or lists facilities such as doctors' offices in your neighborhood based on an address you enter. These applications use network analysis on the server to find the appropriate routes and facilities based on the information you provide. You don't need to have any special network analysis software on your machine to get the results you need, because the server does the work for you and returns the results to your machine via a web service.
Using ArcGIS for Server, you can host similar services that perform transportation network analysis operations such as finding the closest facility, the best route for a vehicle, the best routes for a fleet of vehicles, locating facilities using location allocation, calculating an OD cost matrix, and generating service areas. These services use the Network Analyst extension to perform analysis on a network dataset.
The first step to creating a network analysis service is to use ArcMap to create a map document that contains a network analysis layer. Then, publish the map as a service, ensuring that the Network Analysis capability is enabled. You can consume the resulting service using a variety of tools included with ArcGIS. The following sections explain this process in more detail.
Creating the map document
Before you can publish a network analysis service, you need to use ArcMap to create a map document that, at a minimum, contains the network analysis layer you will use in your service. You can either add an existing network analysis layer by using the Add Data dialog box or create a new network analysis layer based on a network layer (referencing a network dataset) already in the map by using the Network Analyst toolbar. If you want the service to return an image of the resulting analysis on the map, you should also add whatever other layers you want to see in the map and adjust their symbology accordingly.
You can also use ArcMap to set parameters that will be applied in the analysis by default. These include network locations, such as facilities and barriers, and solver properties, like number of facilities to find and restrictions. For more information about working with network analysis layers in ArcMap, see the Network Analyst section of the ArcGIS Help.
Publishing the service
After you have created and saved your map document, you can create the network analysis service by following the steps in How to publish a service. When publishing the resource, keep in mind the following:
In ArcGIS for Desktop, there are two publishing scenarios: one where you copy the data to the server when publishing, and one where you do not copy the data to the server when publishing. If you will not be copying data to the server when publishing, you'll need to explicitly give the ArcGIS Server account read permissions to the data referenced by the map document before you publish. If you'll be copying data to the server when publishing, you do not need to grant the ArcGIS Server account permissions to your data. This process is described in detail in the help topic Making your data accessible to ArcGIS for Server.
When specifying capabilities in the Service Editor, make sure Network Analysis is enabled.
For a detailed example of publishing a network analysis service, see Tutorial: Publishing a network analysis service.
Using the service
You can use network analysis services to provide specialized or locally hosted routing in your desktop applications. For example, the Find Route dialog box in ArcMap and the Route dialog box in ArcGIS Explorer are originally configured to access Esri-hosted network analysis services. If you want to use your own service, either because you have added special rules or data or because you lack an Internet connection, you can reconfigure these commands to use your own network analysis service. This does not require writing any code.
In web applications and other desktop scenarios, network analysis services must be consumed programmatically. ArcGIS developers have many choices of platforms that can work with network analysis services, such as the ArcGIS web APIs and the SOAP and REST APIs. Network analysis on the server is also available through ArcObjects using the coarse-grained object NAServer.
The general pattern for working with a network analysis service is:
- Get a reference to the network analysis service.
- Set up the solver parameters. These include which type of analysis you want to perform and the network locations (for example, stops) to use during the analysis.
- Call the Solve method on the network analysis service, passing in the solver parameters.
- Work with the results returned from the service. This could include displaying the results on the map or reporting driving directions.
Network analysis using ArcObjects
The ArcObjects SDK for the Microsoft .NET Framework provides concepts and samples that can help you get started developing with network analysis services using ArcObjects and SOAP. Visit the following links for more information:
Network analysis with geoprocessing services
If you're not comfortable writing code, you can still add network analysis functionality to your web applications through geoprocessing services. A geoprocessing service works typically from a model that you've built in ModelBuilder or an individual tool that is designed to be published as a service, such as Solve Vehicle Routing Problem or Generate Service Areas. A user submits some input to the geoprocessing service, the model or tool runs on the server, and the results are sent back to the user's machine.
You can also perform any network analysis using live traffic speeds. To do this, you need to set up your own traffic service using the Update Traffic Data geoprocessing tool and point the network dataset that the analysis will be performed on to that service. Alternatively, you can point the network dataset to a traffic service that is available on ArcGIS Online. Make sure that the analysis you set up specifies a traffic-based cost attribute, such as TravelTime, and a start time is specified.
Some of the Esri client APIs vary in the level of complexity that they allow when working with network analysis services. The following table specifies which solvers are available with each API:
|ArcGIS API||Network analysis services||Geoprocessing services|
Route, Service Area, Closest Facility