How to author and publish a geoprocessing model

Copy SDK sample data packages

Complete the following steps to locate and copy the SFNetwork.mpk map package to a directory created for this exercise. You'll use the SFNetwork.mpk sample data that's included when you install the ArcGIS Runtime SDK for Java.

Steps:
  1. Create a new folder named RoutingExercise in a location of your choice.
  2. Locate the SFNetwork.mpk sample data installed with the ArcGIS Runtime SDK for Java.
  3. For example, <install directory>\sdk\samples\data\mpks\SFNetwork.mpk.
  4. Copy the SFNetwork.mpk map package from the sample data folder into your RoutingExercise folder.
  5. Double-click the SFNetwork.mpk package in the RoutingExercise folder to start ArcMap and unpack the map package's files into your Documents library.
  6. For example, ...\Documents\ArcGIS\Packages\SFNetwork\v101.

    Become familiar with the map document and the data it contains.

Create a geoprocessing model

In the following steps, you'll create a geoprocessing model in a new toolbox. You'll add commercial tools to your model, such as the Make Route Layer and Add Locations tools from the Network Analyst Tools toolbox, and configure the model's parameters to use data types supported by ArcGIS Runtime.

Steps:
  1. In the ArcMap Catalog window, right-click the RoutingExercise folder and click New > Toolbox to create a toolbox named RoutingTools.
  2. Right-click the RoutingTools toolbox, and click New > Model to create a model.
  3. NoteNote:

    The model should be open for editing in ModelBuilder. To add tools to your model, continue with the following steps:

  4. From the ArcMap main menu, select Windows > Search to open the ArcMap Search window.
  5. Search Tools for the Network Analyst Make Route Layer tool.
  6. Drag the tool from the search results window to the ModelBuilder window to add an instance of the tool to your model.
  7. Double-click the Make Route Layer tool in the ModelBuilder window to open the tool’s dialog box and review its parameters.
  8. Click the drop-down arrow to the right of the Input Analysis Network field and select your map's Streets_ND network dataset layer.
  9. screen capture of the Make Route Layer dialog box
  10. Click OK to accept the default values for the remaining fields and close the Make Route Layer dialog box.
  11. In the ArcMap Search window, search Tools for the Network Analyst Add Locations tool.
  12. Add an instance of the tool to your model by dragging the tool from the search results window to the ModelBuilder window.
  13. Use the ModelBuilder Connect tool to connect the Make Route Layer tool’s output to the Add Locations tool.
  14. Connect the output as the input parameter Input Network Analysis Layer.
  15. screen capture of the Model dialog box

Modify the model's parameters

For your model to work with applications developed with the ArcGIS Runtime SDK for Java, feature class inputs need to be provided as Feature Set data type parameters. Complete the following steps to designate the Add Locations tool’s Input Locations as a model parameter of the required data type:

Steps:
  1. In the ArcMap Catalog window, create a file geodatabase named FC_Templates in your RoutingExercise folder.
  2. Create a point feature class named RoutePtTemplate in the geodatabase.
    1. Select Point Features as the geometry type and WGS 1984 as the geographic coordinate system.
    2. Accept the default XY Tolerance, Configuration Keyword, and attribute fields.
    3. Click Finish to create the feature class.
  3. In the open ModelBuilder window, right-click the Add Locations tool and select Make Variable > From Parameter > Input Locations.
  4. Click the Auto Layout button then the Full Extent button to arrange the model elements in the ModelBuilder window.
  5. Right-click the Input Locations variable and click Model Parameter on the displayed context menu.
  6. NoteNote:

    A bold letter "P" appears next to the variable indicating that it's now a model parameter.

  7. Right-click the Input Locations variable and click Properties.
  8. Click the Data Type tab. The currently specified data type is Table View .
  9. Using the Data Type field’s pull-down menu, change the data type to Feature Set .
  10. screen capture of the Input Location Properties dialog box

    Configuring your model to use Feature Set inputs is required to support ArcGIS Runtime development. Feature Sets are in-memory feature classes compatible with the runtime’s GPFeatureRecordSetLayer data type.

Define feature set schema and symbology

The attribute schema and spatial reference for a feature set is imported from a template feature class. No particular attribute schema is required for this exercise, so a basic point feature class using the WGS 1984 geographic coordinate system will suffice. Follow these steps to complete the Input Locations Feature Set input's configuration:

Steps:
  1. On the open Input Locations Properties dialog box, click the browse button to the right of the Import schema and symbology from field.
  2. screen capture showing the browse button to the right of the 'Import schema and symbology from' text
  3. Browse to the RoutePtTemplate feature class you created in the FC_Templates geodatabase.
  4. Click OK to apply the changes to the Input Locations model variable and close the Properties dialog box.
  5. If you have not already done so, save your model by clicking Model > Save.
  6. All of the nodes in your model are now colored indicating that the model is ready to run.

    screen capture of the Model ready to run

    Your feature set's label Input Locations will be used as the input parameter name when an ArcGIS Runtime geoprocessing task is created to consume your model. It is recommended that the names you assign your model variables be descriptive but simple enough for application developers to program against.

Complete the geoprocessing model

The geoprocessing model is nearly complete. Complete the following steps to add the Solve and Select Data tools and configure your model’s output parameter:

Steps:
  1. If your model is not already open for editing in ModelBuilder, right-click the model in the ArcMap Catalog window and click Edit.
  2. In the ArcMap Search window, search Tools for the Network Analyst Solve tool.
  3. Add an instance of the tool to your model by dragging the tool from the search results window to the ModelBuilder window.
  4. Use the Model Builder Connect tool to connect the Add Locations tool’s output to the Solve tool. Connect the output as the input parameter Input Network Analysis Layer .
  5. screen capture of the Model dialog box
  6. Rename the Solve tool's output to Network Analyst Layer.
  7. Use the ArcMap Search window to search Tools for the ModelBuilder Select Data tool.
  8. Add an instance of the tool to your model by dragging the tool from the search results window to the ModelBuilder window.
  9. Connect the Network Analyst Layer output as the Select Data tool’s Input Data Element input parameter.
  10. Double-click the Select Data tool in the ModelBuilder window to open the tool’s dialog box and review its parameters.
  11. Click the drop-down arrow to the right of the Child Data Element field to change the selected value from Stops to Routes. (The Select Data tool allows you to pull a result out of a group result. In this case, the input layer contains the route, barriers, and stops. You'll only use the resulting routes in this exercise.)
  12. Click OK to close the Select Data tool’s parameter window.
  13. Right-click the Select Data tool’s Routes output and make the output a model parameter.
  14. Click the Auto Layout > Full Extent buttons to arrange the model elements in the ModelBuilder window.
  15. From the ModelBuilder main menu, click Model > Model Properties.
  16. Change the Name and Label properties of your model from Model to Route.
  17. On the Properties dialog box, click the Parameters tab and review your model’s parameters.
  18. Your model has only one required input parameter and one derived output parameter. If your model accepted multiple inputs, this is where you see all he parameters, change the order in which scripts and applications are expected to supply their inputs to your model, and verify each parameter’s data type.

  19. Click OK to close the Properties dialog box.
  20. Click Model > Save to save the changes you made to your model.
  21. screen capture of the final Model
  22. Close the ModelBuilder window.

Execute the model and check the results

To run your model from within ArcMap, complete the following steps. The result can be shared as a geoprocessing package.

Steps:
  1. Zoom to an extent at which you can easily select a point on one of the streets from the Streets_ND network dataset.
  2. In the ArcMap Catalog window, double-click the model to open its interface panel.
  3. screen capture of the 'Route' dialog box

    The user interface generated by ArcMap indicates that the model is expecting point features as input. Notice that an in-memory feature class, Route::Input_Locations, has been temporarily added to your Table of Contents as a new layer. Also, a point feature appears to follow your mouse cursor as you pan across the map. ArcMap is waiting for you to sketch point features as input for the tool.

  4. Zoom in if detail from the Streets, Signposts, or RestrictedTurns layers are not displayed; by default, these layers do not display when zoomed-out beyond a certain map scale.
  5. Click any two locations on the map display being careful to select points that intersect streets from one of the layers in the network dataset.
  6. Once you've sketched two points, click OK on the Route tool's interface to run the geoprocessing model.
  7. If you previously disabled background geoprocessing (Geoprocessing > Geoprocessing Options), a modal dialog box will display providing status on the running job. Close this dialog box once the geoprocessing has completed successfully; otherwise, the model will be executed as a background process.

    If you previously selected to have geoprocessing results added to the display (Geoprocessing > Geoprocessing Options), a new feature layer named Route will be added to your map display, and you'll see a route that follows the street network connecting the first point you selected (the route start point) to the second selected point (the route end point).

    If the route is not displayed on your map, you can add it to the map display by dragging the geoprocessing output to the map display from the ArcMap Results window.

    • Open the ArcMap Results window (Geoprocessing > Results).
    • Expand the most recent geoprocessing result for the Current Session.
    • Select and drag the Routes: Routes result to the map display.
    'Results' window

Create a geoprocessing package

Once you've verified that your model executes and produces valid results, you can package the model for distribution. Complete the following steps to have ArcMap complete an analysis of your geoprocessing result. This must be done before the result can be published as a geoprocessing package.

Steps:
  1. From the ArcMap main menu, click Customize > Arcmap Options.
  2. click the Sharing tab and make sure that the Enable ArcGIS Runtime Tools option is checked.
  3. Click Geoprocessing > Results to open the ArcMap Results window.
  4. Expand the most recent geoprocessing result for the Current Session.
  5. Right-click the result and select Share As > Geoprocessing Package from the displayed context menu.
  6. 'Results' window
  7. On the Geoprocessing Package dialog box, select the radio button next to Save package to file and browse to your RoutingExercise folder. Name the output package Route.gpk.
  8. On the Geoprocessing Package dialog, make sure that the Support ArcGIS Runtime option is checked.
  9. Click the Analyze button on the Geoprocessing Package dialog box.
  10. ArcMap analyzes the geoprocessing result and displays any warnings or errors in a dockable window.

    window showing errors and warnings

Correct errors and create the geoprocessing package

Complete the following steps to correct any errors. You can ignore warnings from an analysis in ArcMap, but errors must be addressed before you can create the geoprocessing package.

Steps:
  1. In the Prepare window, right-click the The Route/Input_Locations parameter is missing a syntax dialog explanation error, and select Update Tool Metadata from the displayed context menu.
  2. On the Item Description dialog box, click the Edit button.
  3. Scroll down to the Syntax field with its input parameter and drop-down arrow.
  4. Click the arrow next to the Input_Locations parameter to reveal its text entry field.
  5. Type the following text in the Input_Locations parameter's Dialog Explanation field:
  6. Model requires at least two input point features which intersect street network features in order to determine a route between the sketched route points.

    screen capture showing Dialog Explanation text input
  7. Save your edit and close the Item Description dialog box.
  8. On the ArcMap Geoprocessing Package dialog box, click the Analyze button to re-analyze the result you are attempting to package. Repeat the previous steps (right-clicking any warnings or errors, working to address the warning or error condition, and then rerunning the analyzer).

    Type the following text in the Summary (Required) and Tags (Required) fields:

    Summary (Required):

    Geoprocessing package containing a model which uses commercial Network Analyst tools to complete a point-to-point analysis.

    Tags (Required):

    point-to-point, routing, San Francisco

  9. Once you've addressed all the errors discovered by the analyzer and reviewed the potential impact of ignoring any of the analyzer's warnings, click the Share button to create the geoprocessing package.
  10. NoteNote:

    ArcMap displays a Package dialog box that reports the approximate size of the package being built. This may take several minutes to complete.

You've developed a geoprocessing model within ModelBuilder, run the model within ArcMap, and published the results as a geoprocessing package. Your geoprocessing package, Route.gpk, uses Feature Set inputs, so it can be used to support applications developed using the ArcGIS Runtime SDK for Java.

2/7/2013