The table of contents of StoweStreamNetworksBasemap.mxd is shown below, along with the StoweStreamNetworkTasks toolbox.
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:
- 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.
Learn more about layer symbology files.
The basic steps for creating and using a layer symbology file are
- Run the model from the ArcToolbox window. A new layer is added to ArcMap.
- Right-click the new layer, choose Properties, and 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 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.
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, illustrated below, 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 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.
StoweStreamNetworksBasemap.mxd is published as a map service.
StoweStreamNetworkTasks.mxd is published as a geoprocessing service, as follows:
- In ArcCatalog, navigate to your server, right-click and 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 geoprocessing.
- 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 will be transported back to the client. If you left the number of records to the default 500, none of the tasks would return any records since they all generate more than 500 records.
- For testing purposes, check Show Messages.
- 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.
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.
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 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.
- In the Properties dialog box, click the Parameters tab, as illustrated below.
- 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.
- In the Range dialog box, enter the minimum and maximum value.
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.