In ArcGIS Desktop, geoprocessing services and tasks appear as toolboxes and tools and can be used like any other geoprocessing tool. You can add a task to a model by dragging it from the Catalog window into ModelBuilder or by using Add Data or Tools from the ModelBuilder main toolbar.
The steps below guide you through the process of connecting to Esri's sample server, running a task from its dialog box, and creating a model tool that uses the task in ModelBuilder. The sample service is Elevation/ESRI_Elevation_World and contains one task, Viewshed, which calculates the likely areas one could observe within a 15-kilometer buffer.
Connect to the Esri sample server
- In the GIS Servers node in the Catalog window, make a new connection to Esri's SampleServer1 by double-clicking Add New GIS Server.
- On the Add ArcGIS Server dialog box, choose Use GIS Services. Click Next.
- For Server URL, enter http://sampleserver1.arcgisonline.com/ArcGIS/services, as illustrated below.
You are now connected to the Esri sample server. In the GIS Servers node, there will be a new connection, ArcGIS on sampleserver1.arcgisonline.com (user).
- Expand the connection and browse to the Elevation folder. Find the ESRI_Elevation_World service with the Viewshed task inside.
Using the task dialog box
The steps below show how to execute the Viewshed task using its tool dialog box.
- Before you execute the task, you'll need a world topographic basemap. Add one by clicking Add Basemap on the ArcMap Standard toolbar (Add Basemap is found by clicking the down arrow next to Add Data ). Choose the Topographic basemap.
- In the Catalog window, double-click the Viewshed task to open its dialog box.
- Alternatively, you can right-click Viewshed and choose Open.
This task requires two inputs: a point feature set (point location) and a linear unit (distance). The output is a polygon that represents the area visible from the input point.
The viewshed service has logic that limits a maximum viewshed to 20km (20,000 meters). Any input distance value greater than this will be reduced to 20 km at execution time.
- Click the Show Help button; the dialog box expands to show the side-panel help. Unlike tools in a local toolbox, tasks do not have individual parameter help.
- Click the Tool Help button to view detailed help in your default Internet browser.
Alternatively, you can right-click Viewshed in the Catalog window and choose Help to view detailed help.
- On the tool dialog box, click Input_Observation_Point and click on your map to add a start point. The illustration below shows adding a point in the hills of San Francisco.
- Instead of digitizing a point, you can choose an existing point feature layer as your input starting point by clicking the down arrow on the Input Observation Point parameter, as illustrated below, where the layer StartPoint is chosen for input. Only the first point of your feature layer will be used; subsequent points are ignored.
- Click OK to run the tool.
After the tool runs, a new polygon feature layer is added to the ArcMap table of contents and a new result is added to the Results window.
Creating a model tool that uses the task
The steps below assume you have some knowledge of creating a new model, adding tools to the model, connecting data to tools, and exposing parameters. You'll create a model and save it to a custom toolbox. If you don't have a custom toolbox, follow the steps in the topic Creating a toolbox. Create the toolbox in your working directory.
The following workflow assumes you have a polygon dataset with a numeric value that needs to be tabulated based on overlapping input. The model you will construct creates a viewshed based on a given input point. Using the viewshed, an approximate population that falls into that viewshed is calculated from census block groups. The Tabulate Intersection tool is used to determine the population within the study area. Any polygon type data could be substituted into this workflow as long as there is an integer value associated with each feature.
- In the steps that follow, you'll create a model and save it to a custom toolbox. If you don't have a custom toolbox, follow the steps in the topic Creating a toolbox. Create the toolbox in your working directory.
- Create a new model by clicking the ModelBuilder tool on the Standard toolbar.
- From the Catalog window, drag the Viewshed task onto the ModelBuilder canvas.
- Rename the Viewshed task Viewshed Service.
- Add the Make Feature Layer tool to the ModelBuilder canvas. Drag the census block data (or appropriate data) into the ModelBuilder canvas. Connect the input data to the Make Feature Layer tool.
- Open the Make Feature Layer tool element inside the ModelBuilder window.
- Check the Use Ratio Policy check box for each field that you will tabulate.
- Accept the change by clicking OK on the tool dialog box.
- Add the Tabulate Intersection tool to the model. You can use the Search window to find the tool and then drag it onto the ModelBuilder canvas.
- Using the Add Connection tool in ModelBuilder, connect the output of Viewshed Service to Tabulate Intersection as Input Zone Features. Connect the output from Make Feature Layer to the Tabulate Intersection tool as Input Feature Class.
- Open the Tabulate Intersection tool by double-clicking it.
- Set Zone Field to grid_code; this is a known field within the results of the viewshed service.
- Accept the change by clicking OK on the tool dialog box.
- Add the Summary Statistics tool and connect the output of Tabulate Intersection to it.
- Open the Summary Statistics tool by double-clicking it.
- Choose an appropriate value for Statistics Field. Set Statistic Type appropriately. This example uses the TotalPop field from the census block group and performs a SUM.
- Expose the Input Observation Point, Viewshed Result, and Summary Table Output variables as model parameters.
Your model should look similar to the illustration below:
- Save your model to your custom toolbox. You can accept the default name (Model in this case) or supply your own name for the model. Exit ModelBuilder.
- In the Catalog window, double-click your model tool to open its dialog box.
- Alternatively, right-click your model tool and choose Open.
- Provide an input point somewhere in your study area.
- Click OK to run the model tool. The illustration below shows an input point on the east side of the Blue Mountains, west of Collingwood, calculating a population of over 16,000 people inside the viewshed area.
Publish as service
You could, at this point, publish your model as a service. This would require an administrator connection to any ArcGIS Server. When your service executes, it will, in turn, execute the Viewshed task on Esri's sample server.
Advanced: Using iteration to calculate viewsheds for multiple points
The previously created model processes a single input location at a time, calculating the viewshed and determining the population. The viewshed service you connected to will accept multiple points and will create individual viewsheds for each input point. The model could be altered to use an iterator to loop over the multiple input points, creating viewsheds and returning population calculations for each viewshed. The following model makes use of an iterator to perform this task.
The Iterate Row Selection tool at the start of the model will run the workflow for each input point. The Collect Values tool gathers each viewshed result and summary statistic output to add to the display. The inline variable (%Value%) uses the Value output from Iterate Row Selection to create unique output names.