ArcGIS Server Banner

GP Service example: More Stream network

GP Service example: More Stream network

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.


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, user enters 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 Key concepts for geoprocessing services.

Corresponding Folder

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

About this example

This example builds upon 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 back, 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 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.

Stowe Stream Networks map document

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

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, illustrated below, 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 will be listed and the user will pick one. (Note that the raster layers will not be listed since they are not features. Nor will any of the sublayers in the tool layers be listed because ArcGIS Server automatically filters out any tool layers and their sublayers from the list of feature layers.) The underlying features will then be copied to the scratch workspace and, when transported back to the client, will be 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 illustrated below.

Create Stream Network model modification

Publishing

StoweStreamNetworksBasemap.mxd is published as a map service.

StoweStreamNetworkTasks.mxd is published as a geoprocessing service, as follows:

  1. In ArcCatalog, navigate to your server, right-click and 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 geoprocessing.
  4. Click Next. From this point on, you can accept the default values provided by the wizard.

Learn more about publishing geoprocessing services with a source map document

Using

To use the service, start ArcMap with a blank document, 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 you didn't set the Maximum Number of Record Returned by Server parameter 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 ArcToolbox 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. In the Properties dialog box, click the Parameters tab, as illustrated below.
  3. Click the Filter cell in the Minimum upstream area in hectares parameters and choose Range. The Range dialog box will automatically open, as illustrated below.
  4. In the Range dialog box, enter the minimum and maximum value.

Applying a range filter

After making this change to Create Stream Network, you need to stop and restart the service 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 in order for the user to see the message.

See Also

  • GP Service example: Stream network
  • Guide to the geoprocessing service examples