Skip To Content

Geoprocessing service example: Watershed

Complexity: BeginnerData Requirement: ArcGIS Tutorial Data for Desktop

Folder

Watershed

Purpose

Using the ArcGIS Spatial Analyst, this basic service computes a watershed polygon.

Services

StoweBasemap (map service), StoweWaterSheds (geoprocessing service).

Geoprocessing tasks

Create Watershed Polygon

Inputs

User digitizes a point in the study area.

Outputs

Polygon of computed watershed and a snapped pour point.

Data

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

Extensions

ArcGIS Spatial Analyst.

About this example

Corresponding folder

The data for this example can be downloaded from ArcGIS.com. Once downloaded, extract the zip file to C:\arcgis\ArcTutor\. The GP Service Examples\Watershed folder contains the completed model and data. This example will copy all of the data to the ArcGIS Server machine during publishing.

Set up GIS Server connections

You will need to set up a publish or administrator connection to your GIS Server in order to publish and use your geoprocessing service. You can optionally set up a user connection which will allow you to only use your geoprocessing services.

  1. In the Catalog window, navigate to the GIS Server node and double-click Add ArcGIS Server.
  2. Choose Administer GIS Server and click Next.
  3. Enter the URL for your GIS Server, for example, http://myserver:6080/arcgis/. Provide a user name and password and click Finish. You now have a connection to your GIS Server under the GIS Servers node of your Catalog window.

Data familiarization

Data

The data that provides input for the models is in c:\arcgis\ArcTutor\GP Service Examples\Watershed. The data is for the town of Stowe, Vermont. The contents of this location are shown below:

Tool and data which makes up the Watershed sample
  • dem_fill is the result of executing the Fill tool using elevation as input.
  • Hillshade is the result of executing the Hillshade tool using dem_fill as input.
  • flowdir is the result of executing the Flow Direction tool using dem_fill as input.
  • accumulation is the result of executing the Flow Accumulation tool using flowdir as input.

Basemap

Open the basemap, StoweBasemap.mxd, located in C:\arcgis\ArcTutor\GP Service Examples\Watershed. The map contains three layers: Landuse (landuse raster), Hillshade (hillshade raster), and Roads (Stowe.gdb/roads feature class).

Reference map and legend

The hillshade layer is drawn with a transparency of 55 percent. To change the transparency, right-click the hillshade layer, choose Properties, click the Display tab, then change the transparency.

The map service will provide a reference for using your geoprocessing service. Publish the StoweBasemap map document to your server.

  1. Within ArcMap, choose File > Share As > Service from the main menu.
  2. In the first panel, choose Publish a service and click Next.
  3. Select the administrator connection you made previously.
  4. Accept the suggested default service name of StoweBasemap and click Next.
  5. Accept the suggested default to publish to the existing root folder and click Continue.
  6. Press the Publish Publish button to publish the service.

You can test the StoweBasemap service by starting ArcMap with a blank document, navigating to your GIS Server and adding the StoweBasemap map service. Enable the connection made previously by double-clicking it. Find the StoweBasemap service and drag it into your map window.

Model

Open the StoweHydro map document. This map document provides a reference to the raster layers, which the model requires.

The model in this example, Create Watershed Polygon, is found inside the StoweWatersheds toolbox. Edit the model and examine the tools and input that make up the model.

Create Watershed Polygon

The Flow Accumulation and Flow Direction variables are raster layers within the map document. The Pour Point variable is a feature set with symbology and attributes set inside the feature template of the PourPoint layer file.

Execute and publish the model

Execute the tool once to ensure it works correctly. Once it executes on your local desktop, publish the result to your GIS Server.

Run the model

In order to create a geoprocessing service, you must run your tool to create a result in the Results window.

  1. In the Catalog window, navigate to the StoweWaterSheds toolbox and expand it. Double-click the Create Watershed Polygon model. The Create Watershed Polygon tool dialog box opens.
  2. Using the Pour Point parameter control, digitize a point on the map.
  3. Run the tool by clicking OK.
  4. The output watershed will be added to the map.
  5. If the Results window is not already open, choose Geoprocessing > Results from the ArcMap main menu to open it.

Publish the result

With a successful result in the Results window, publish the service.

  1. In the Results window, right-click the Create WaterShed Polygon result and choose Share As > Geoprocessing Service. This will start the Share As Service wizard.
  2. In the first panel, choose Publish a service and click Next.
  3. Select the publisher or administrator connection you made at the start of this exercise.
  4. Provide a name for the service, such as StoweWaterSheds, and click Next.
  5. Accept the suggested default to publish to the existing root folder and click Continue.
  6. The Service Editor will appear; press the Analyze Analyze button. You should not encounter any errors, only warnings that the data will be copied to the server during the publish process. You can safely ignore these messages.
  7. Select the Parameters tab from the left side of the Service Editor.
    • Enable full messages by setting the Message Level to Info.
    • Because the Create Watershed Polygon task executes quickly and returns a small polygon, set the Execution Mode to Synchronous.

      Publishing the StoweWaterSheds service

  8. Click the Preview Preview button to see how the tool dialog box will appear when the Create Watershed Polygon task is used in ArcMap.
  9. Click the Publish Publish button to create and start the service.

Use the service

  1. Start ArcMap with a blank document.
  2. Add the StoweBasemap map service to the ArcMap table of contents from your GIS Server user connection.
  3. Expand the StoweWaterSheds geoprocessing service from the GIS Server user connection, and double-click the Create Watershed Polygon task to open its tool dialog box.
  4. Add a point to the Create Watershed Polygon task using the feature set control.
  5. Click OK to run the task.

    After the task completes, the table of contents has the two output layers, as illustrated below:

    Output from Create Watershed Polygon task added to the ArcMap table of contents
  6. Examine the results of the task in the Results window, as illustrated below:

Related topics