Tutorial: Using geoprocessing tasks in Desktop

In ArcGIS for 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 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

Steps:
  1. In the GIS Servers node in the Catalog window, make a new connection to Esri's SampleServer1 by double-clicking Add New GIS Server.
    1. On the Add ArcGIS Server dialog box, choose Use GIS Services. Click Next.
    2. For Server URL, enter http://sampleserver1.arcgisonline.com/ArcGIS/services, as illustrated below.

      Connecting to Esri SampleServer1

    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).

  2. 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.

Steps:
  1. Before you execute the task, you'll need a world topographic basemap. Add one by clicking Add Basemap Add Basemap on the ArcMap Standard toolbar (Add Basemap is found by clicking the down arrow next to Add Data Add Data). Choose the Topographic basemap.
  2. 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.

    NoteNote:

    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.

    1. 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.
    2. 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.

  3. 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.

    Viewshed service dialog box

    • 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.

      Using an existing layer in the feature set input of the viewshed service

  4. 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.

NoteNote:

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.

Steps:
  1. 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.
  2. Create a new model by clicking the ModelBuilder tool ModelBuilder on the Standard toolbar.
  3. From the Catalog window, drag the Viewshed task onto the ModelBuilder canvas.
    • Rename the Viewshed task Viewshed Service.
  4. 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.
    1. Open the Make Feature Layer tool element inside the ModelBuilder window.
    2. Check the Use Ratio Policy check box for each field that you will tabulate.
    3. Accept the change by clicking OK on the tool dialog box.
  5. 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.
  6. Using the Add Connection tool Add Connection 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.
    1. Open the Tabulate Intersection tool by double-clicking it.
    2. Set Zone Field to grid_code; this is a known field within the results of the viewshed service.
    3. Accept the change by clicking OK on the tool dialog box.
  7. Add the Summary Statistics tool and connect the output of Tabulate Intersection to it.
    1. Open the Summary Statistics tool by double-clicking it.
    2. 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.
  8. Expose the Input Observation Point, Viewshed Result, and Summary Table Output variables as model parameters.

    Your model should look similar to the illustration below:

    Completed model using the viewshed service
  9. Save 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.
  10. In the Catalog window, double-click your model tool to open its dialog box.
    • Alternatively, right-click your model tool and choose Open.
  11. Provide an input point somewhere in your study area.
  12. 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.

    The resulting viewshed from Esri SampleServer1 with the calculated population

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.

Learn more about creating a geoprocessing service

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.

Using an iterator to create multiple viewsheds for analysis

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.

Learn how Collect Values works in ModelBuilder

Related Topics

5/6/2015