Geoprocessing service example: Geometric Network Trace

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data for Desktop

Folder

TraceGeometricNetwork.

Purpose

Using a point specified by the user, perform a trace on a geometric network Montgomery (map service), TraceGeometricNetwork (geoprocessing service).

Services

Montgomery (map service), TraceGeometricNetwork (geoprocessing service).

Geoprocessing tasks

TraceGeometricNetwork.

Inputs

Geometric Network, point location from which to start trace.

Outputs

A feature layer containing the system valves features output from the trace.

Data

The example uses a water network to demonstrate the tracing capabilities through geoprocessing.

Extensions

None.

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\TraceGeometricNetwork folder contains the completed models and data.

About this example

This example shows the detailed steps of sharing and using a map and a geoprocessing service. The model TraceGeometricNetwork used in the service is derived from the Trace Geometric Network tool. The geoprocessing task lets you select a point on a water network from which to run a trace. The result of the trace will be a feature layer containing all the values upstream from the start of the trace.

Data

The study area for this example is a water network. Data includes standard aspects of a water network such as mains, laterals, and valves. Also included are roads and parcels for the area of interest. The data can be found in C:\arcgis\ArcTutor\GP Service Examples\TraceGeometricNetwork\ToolData\Montgomery.gdb.

Model and tool data

The toolbox for the geoprocessing service is TraceGeometricNetwork.tbx, and the source map document for the service is TraceGeometricNetwork.mxd. TraceGeometricNetwork.mxd contains several source data layers: a layer for each feature class in the geometric network as well as layers for roads and parcels. Only the layers that participate in the geometric network are used by the TraceGeometricNetwork model.

Open the TraceGeometricNetwork map document from your Catalog window by double-clicking it.

Model overview

To better understand the model, expand the TraceGeometricNetwork.tbx toolbox, right-click the TraceGeometricNetwork model, and click Edit. The TraceGeometricNetwork model is illustrated below. There are two input variables, Flags and Barriers. Each of these variables is a feature set of points that allows you to interactively define features as input to the model.

The input points supplied by the Flags and Barriers variables are snapped to distribution main features using the Snap tool. Flag Locations is used as input for the start of the trace, and Barrier Locations is used to disable features from the trace.

TraceGeometricNetwork model

The model performs an upstream trace from the snapped Flag Locations point(s) using the Trace Geometric Network tool and returns the traceResults layer identifying any valves upstream from the input flag point(s). The Select Data tool is used to extract the values, and the Make_Feature_Layer tool is used to create a layer containing just the traced valves.

Make a server connection managing for publishing

Make sure you have the permission to publish to the server. If you do, follow the steps below to create a publisher or management connection to a server:

Steps:
  1. Go to GIS Servers > Add ArcGIS for Server to bring up the Add ArcGIS Server dialog box.
  2. Check Publish GIS Services or Administer GIS Server.
  3. On the General panel, enter a value for Server admin URL and provide values for User Name and Password.
  4. Click Finish to complete the connection.

Share a map service

Follow the next steps to create a map service that users of your service can use as a reference map:

Steps:
  1. From the Catalog window, navigate to C:\arcgis\ArcTutor\GP Service Examples\TraceGeometricNetwork.
  2. Open TraceGeometricNetwork.mxd.
  3. From the ArcMap main menu, choose File > Share As > Service. The Share As Service wizard opens.
  4. In the first panel of the Share As Service wizard, choose Publish a Service and click Next.
  5. In the Choose a connection drop-down list, choose the name of the server you connected to previously. The default value for Service name is TraceGeometricNetwork (the name of the map document). You can accept the default name or enter a new one.
  6. In next panel, provide your service folder or accept the default of [root] and click Continue. The Service Editor dialog box opens.
  7. In the Service Editor, click the Capabilities tab. Mapping and KML are checked by default. KML capability is not needed for this service, so uncheck the KML check box.
  8. Click the Item Description tab and enter the required text for Summary and Tags.
  9. Click the Analyze button Analyze on the upper right of the Service Editor. The Prepare window opens.
  10. If you see any warning or error messages in the Prepare window, fix them by right-clicking the row with the error or warning message and clicking the highlighted message.
  11. After you've resolved any errors, click the Publish button Publish on the upper right of the Service Editor. You should get a successful message when publishing completes.

The TraceGeometricNetwork map service is published and ready for use.

Share a geoprocessing service

Steps:
    You need to run the tool at least once to share the tool as a service. To run the tool, follow these steps:
  1. In the Catalog window, navigate to C:\arcgis\ArcTutor\GP Service Examples\TraceGeometricNetwork.

    Although you do not need to make any edits to the data and documents in this directory, a good practice is to copy and paste the entire TraceGeometricNetwork directory to another local directory. This allows you to explore the data and documents in the copied directory and make edits while preserving the original contents.

  2. Open TraceGeometricNetwork.mxd.
  3. Run the TraceGeometricNetwork model tool to create an output layer:
    1. From the ArcMap main menu, choose Geoprocessing > Environments. The Environment Settings dialog box opens.
    2. Click the Workspace category.
  4. In the Catalog window, click the Go To Home Folder button Go To Home Folder. Expand TraceGeometricNetwork.tbx and double-click the model tool TraceGeometricNetwork to open its dialog box.
  5. For the Flags parameter, click along a distribution main from which you want to start the trace.
  6. Click OK to run the tool.

    When the tool finishes executing, a new result is written to the Results window. To open the Results window, choose Geoprocessing > Results in the ArcMap main menu.

  7. Check that the tool executed successfully by examining the result in the Results window. A failed execution displays an error icon Error next to the result.

Steps:
    To create a geoprocessing service, you share a result.
  1. In the Results window, right-click the TraceGeometricNetwork result and choose Share As > Geoprocessing Service. The Share As Service wizard opens.
  2. Choose the server you connected to previously and publish to the same folder as the map service you created previously. The default name of the service is the same as the tool name, TraceGeometricNetwork. You can accept the default service name or enter a new name.
  3. On the last panel of the Share As Service wizard, click Continue to open the Service Editor.
  4. You can accept all the default values for the geoprocessing service and click the Publish button Publish to publish the service.
    See A quick tour of publishing a geoprocessing service for more information on using the Service Editor to publish a geoprocessing service.

Using the geoprocessing service

The following steps show how to use the map and geoprocessing services that you previously published.

Steps:
  1. Open a new ArcMap document.
  2. In the Catalog window, do the following:
    1. Navigate to your server connection under GIS Servers, select the map service TraceGeometricNetwork, and drag it into the ArcMap table of contents.
    2. Expand the TraceGeometricNetwork map service in the table of contents. You see all the layers belonging to the TraceGeometricNetwork map service.
  3. In the Catalog window, navigate to your server connection under GIS Servers, find the geoprocessing service that you published in the previous section, and expand it. The task TraceGeometricNetwork appears.
  4. Double-click the TraceGeometricNetwork task to open the task dialog box.
  5. On the TraceGeometricNetwork dialog box is the Flags parameter as illustrated below. Click the Flag parameter in the tool dialog box and click a distribution main in the map service from which you want the trace to start. Optionally, click the Barriers parameter and click on a distribution main feature to block the trace from any of those features. If you choose not to specify any barriers, a warning that empty output will be generated is displayed.
  6. TraceGeometricNetwork tool dialog box
  7. Click OK to run the geoprocessing task.

    The output is returned from the server and written to the location set in your geoprocessing scratch workspace environment.

When the task completes, the output is added to ArcMap as a feature layer.

Trace result

Related Topics

12/18/2014