GP Service example: More Stream network

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data Setup

Folder

StreamNet2

Purpose

User can download a precomputed network or create their own.

Services

StoweStreamNetworksBasemap (map service) StoweStreamNetworkTasks (geoprocessing service).

Geoprocessing tasks

Get Precomputed Stream Network, Create Stream Network.

Inputs

For the Get Precomputed Stream Network task, the user inputs a layer name. For Create Stream Network, the user enters the minimum upstream area in hectares.

Outputs

Stream network

Data

This example uses digital elevation data (raster) and other data found in the Spatial Analyst tutorial.

Extensions

Spatial Analyst.

Of note

Uses layer symbology files (.lyr) to instruct the client application on how to draw the output stream networks, as described in the GP Watershed service example.

About this example

Corresponding Folder

C:\arcgis\ArcTutor\GP Service Examples\StreamNet2 contains the completed model and data.

About this example

This example builds on the Create Stream Network task created in GP Service example: Stream network. As discussed in that example, the primary purpose of the task was to produce a stream network for cartographic display, allowing the user to produce several different networks, ultimately choosing one that suits their cartographic needs. The Create Stream Network task used a result map service to display its results.

In this example, stream network features are transported to the client for display. Since the features are transported to the client application, a result map service is not needed . The service contains two tasks, one to fetch precomputed networks and another to create a new network.

The illustration below shows the final resulting StoweStreamNetworksBasemap map service table of contents and the geoprocessing tasks in the StoweStreamNetworkTasks geoprocessing service.

Basemap with geoprocessing service

The basemap service allows you to view five precomputed networks, ranging from 10 to 50 hectares. There are two geoprocessing services:

Basemap

The table of contents of StoweStreamNetworksBasemap.mxd is shown below, along with the StoweStreamNetworkTasks toolbox as shown in the Catalog view.

Stowe Stream Networks map document

The five stream network layers were created using the Precompute a Stream Network model. This is a utility tool and is not part of the geoprocessing service. Precompute a Stream Network is similar to the Create Stream Network with the following differences:

Precompute a stream network model

Models

The contents of StoweStreamNetworkTasks.mxd are illustrated below.

Stowe Stream Network Tasks map document

The table of contents has the same precomputed stream network layers as found in StoweStreamNetworksBasemap.mxd. These layers were created as follows:

  1. Each stream network layer in StoweStreamNetworksBasemap.mxd was saved as a layer file to the ToolData directory.
  2. Using Add Data Add Data in StoweStreamNetworkTasks.mxd, each layer file created above was added to the table of contents.

The Get Precomputed Stream Network model is a simple model that copies the contents of a feature layer to the scratch workspace.

Get Precomputed Stream Network model

The input variable, Network to download, is a Feature Layer data type. When the task executes, all feature-based layers are listed, and the user picks one. (Note that the raster layers are not listed since they are not features. Nor are any of the sublayers in the tool layers listed, because ArcGIS Server automatically filters out any tool layers and their sublayers from the list of feature layers.) The underlying features are then copied to the scratch workspace and, when transported back to the client, drawn using the symbology defined in ToolData/Stream Network.lyr.

The Create Stream Network task is the same as found in GP Service example: Stream network with one notable exception: the output variable, Stream Network, has its Layer Symbology property set to Stream Network.lyr, as shown below.

Create Stream Network model modification

Publishing

StoweStreamNetworksBasemap.mxd is published as a map service.

StoweStreamNetworkTasks.mxd is published as a geoprocessing service:

  1. In the Catalog window, navigate to your GIS Server, right-click, then choose Add New Service. Name the service StoweStreamNetworkTasks and choose Geoprocessing Service as the type.
  2. Click Next.
  3. Choose StoweStreamNetworkTasks.mxd as the source for your service.
    • Change the Maximum Number of Record Returned by Server to 10000. You need to change this because there is no result map service to draw the results, and the features are transported back to the client. If you leave the number of records to the default 1000, none of the tasks return the full dataset, since they all generate more than 1,000 records.
    • For testing purposes, check Show Messages.
  4. Click Next. From this point on, you can accept the default values provided by the wizard.

Using

To use the service, start ArcMap with a blank document and add the StoweStreamNetworksBasemap map service and the StoweStreamNetworkTasks geoprocessing service. Open and execute both tasks. If you do not get results from either of the tasks, it is probably because the Maximum Number of Record Returned by Server parameter was not set to a large number as described above.

Using a range filter

Model tool parameters can have filters, which are used to validate parameter values. For Create Stream Network, you can use a range filter to validate the Minimum upstream area in hectares parameter. Minimum areas less than 5 hectares produce thousands of stream segments and generate unusable output (at least for cartographic display purposes). You can use a filter to prevent processing for any values less than 5 hectares.

To set a range filter

  1. In the Catalog window, right-click the Create Stream Network tool and click Properties. Alternatively, with Create Stream Network open in ModelBuilder, click Model in the main ModelBuilder menu, then click Model Properties.
  2. On the Properties dialog box, click the Parameters tab.
  3. Click the Filter cell in the Minimum upstream area in hectares parameters and choose Range. The Range dialog box will automatically open.
  4. On the Range dialog box, enter the minimum and maximum values.
Applying a range filter

After making this change to the Create Stream Network model, the service must be restarted for the change to take effect.

With these changes, anytime a value less than 5 is entered, the task will display an error in its messages. The service must have Show Messages checked for the user to see the message.

Related Topics


4/15/2011