Creating models for geoprocessing services

There are certain rules that must be followed when creating models suitable for publishing to ArcGIS Server:

To view some completed models and services, see Guide to geoprocessing service examples.

Data types

Models can only use certain input and output parameter data types, as discussed in detail in Key concepts for geoprocessing services and Input and output data types.

For existing models, the most common modification you need to make is to change input feature class variables, which are not supported by ArcGIS Server, to feature set variables, which are supported by ArcGIS Server.

Some data types, such as TIN, are not allowed for parameters, and the model will not publish. You will receive an error when publishing, as illustrated below.

Error dialog for invalid data type

Other parameter data types will publish, but they will be transformed to a string data type. For example, an areal unit data type will become a string data type in the published task. If your model has a converted data type as an input parameter, you will need to change its type to string and convert it to your desired data type within your model.

Learn more about converting to and from string data types

Intermediate and output data

When your task executes, ArcGIS Server creates a job directory where you can write the intermediate and output data of your model, as illustrated below. You must write your intermediate data and output data to either the scratch folder or the scratch geodatabase.

Intermediate and output data location

Rules for intermediate data

  • In ModelBuilder, right-click any intermediate data variable and choose Managed.
    CautionCaution:

    Do not set output variables to Managed, only intermediate variables.

  • Use variable substitution (%scratchworkspace%) for paths. For example:
     %scratchworkspace%/templines.shp
     %scratchworkspace%/scratch.gdb/outWatershed
  • Write data to memory. For example:
    in_memory/tempdata
    Be sure you understand the limitations of using in_memory before using this location.

    Learn more about the in_memory workspace

Rules for output data

Output data must be written to one of the following:

  • %scratchworkspace%/<dataset>
  • %scratchworkspace%/scratch.gdb/<dataset>
  • in_memory/<dataset> if, and only if, there is no result map service for your geoprocessing service

    When you use a result map service, it's important to realize that there are two services—the geoprocessing service and the result map service. These two services execute independently of each other. When the task executes, ArcGIS Server executes the geoprocessing task first, then executes the result map service to draw the output of the geoprocessing service. Because of this execution order, the result map service needs datasets on disk produced by the geoprocessing service. This means that the output of the tasks in the geoprocessing service must be physical datasets on disk, not layers or in-memory datasets.

NoteNote:
  • Do not make your output data managed.
  • Do not write output data to in_memory if you have a result map service. Be sure you understand the limitations of using in_memory before writing data to this location.
  • Do not set the scratch workspace for any model processes. Do not set the scratch workspace for the model.

Using the tool share folder structure

When you are developing tools and map documents for publishing, you should use the tool share folder structure to gather together your resources—toolboxes, map documents, data, and documentation. This folder structure contains a scratch folder with a scratch file geodatabase, just like the geoprocessing service job directory that ArcGIS Server creates for your task, as illustrated below. By using the tool share folder structure and setting your workspace to the scratch folder, you are emulating ArcGIS Server, which makes testing and debugging your tool much easier.

Setting scratch workspace in the ToolShare folder structure

Related Topics


11/18/2013