GP Service example: More Stream network
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. |
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.
The basemap service allows you to view five precomputed networks, ranging from 10 to 50 hectares. There are two geoprocessing services:
- Get Precomputed Stream Network—The user chooses a precomputed stream network, and the features are transported back.
- Create Stream Network—The user creates a new network by entering an upstream drainage area. This is a slightly modified version of the Create Stream Network task discussed in the GP Service example: Stream network.
Basemap
The table of contents of StoweStreamNetworksBasemap.mxd is shown below, along with the StoweStreamNetworkTasks toolbox as shown in the Catalog view.
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:
- The input variable is named Area.
- The accumulation and flowdir raster dataset variables refer to raster datasets in the ToolData folder rather than layers in the ArcMap table of contents. This allows you to execute the model without having the raster layers in the ArcMap table of contents.
- The Stream Network variable has a Layer Symbology file.
The basic steps for creating and using a layer symbology file are
- Run the Precompute a Stream Network model from the Catalog window. A new layer is added to ArcMap.
- Right-click the new layer, choose Properties, then click the Symbology tab.
- Change the symbology to Graduated Symbols using GRID_CODE as the value. Use a Natural Breaks (Jenks) classification.
- Right-click the layer in the table of contents and click Save As Layer File. Save to ToolData/Stream Network.lyr
- Edit the Precompute a Stream Network model.
- Right-click the Stream Network output variable and click Properties.
- In the Properties dialog box, click the Layer Symbology tab and enter the layer file created above.
Models
The contents of StoweStreamNetworkTasks.mxd are illustrated below.
The table of contents has the same precomputed stream network layers as found in StoweStreamNetworksBasemap.mxd. These layers were created as follows:
- Each stream network layer in StoweStreamNetworksBasemap.mxd was saved as a layer file to the ToolData directory.
- Using 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.
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.
Publishing
StoweStreamNetworksBasemap.mxd is published as a map service.
StoweStreamNetworkTasks.mxd is published as a geoprocessing service:
- 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.
- Click Next.
- 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.
- 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
- 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.
- On the Properties dialog box, click the Parameters tab.
- Click the Filter cell in the Minimum upstream area in hectares parameters and choose Range. The Range dialog box will automatically open.
- On the Range dialog box, enter the minimum and maximum values.
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.