Authoring geoprocessing tasks with ModelBuilder
In this topic
- Creating results from models
- Intermediate data
- Writing output data to in_memory
- Differences between 10.0 and later versions
- Getting started with ModelBuilder
As described in A quick tour of authoring and sharing geoprocessing services, authoring a geoprocessing service entails authoring the tasks within the service. Authoring a task means selecting or creating a tool, defining the input and output parameters of the task, and the location of any data used by the task. More often then not, you create tasks by sharing custom tools created with ModelBuilder or Python.
ModelBuilder is an application you use to create, edit, and manage models. Models are workflows that string together sequences of geoprocessing tools, feeding the output of one tool into another tool as input. ModelBuilder can be thought of as a visual programming language for building workflows. Models and ModelBuilder are an easy way to author geoprocessing tasks.
If you are unfamiliar with models and ModelBuilder, skip to the Getting started with ModelBuilder section below for a list of useful topics.
If you have an existing model with parameters that you can run successfully in ArcGIS for Desktop, you can share it in a service without modification. The remainder of this topic addresses some of the finer points of authoring tasks with ModelBuilder.
Creating results from models
Services are created by right-clicking a result in the Results window. In order to create a result, a model must be run as a tool, either by opening its dialog box from the Catalog or ArcToolbox window, or running it in the Python window.
A result is not created when you run a model within ModelBuilder.
In the vast majority of cases, your model will need to have parameters. You can see an example of a model tool with parameters in A quick tour of authoring and sharing geoprocessing services. You can learn more about creating model tools in the topic A quick tour of creating tools with ModelBuilder.
Intermediate data is data created by the model but is not an output of the model. Intermediate data created by a task is automatically deleted by ArcGIS Server.
When using ModelBuilder in ArcGIS for Desktop, you have to explicitly set model variables as intermediate data in order for the intermediate data to be deleted after the model is run. This is not the case with server tasks: any data created by the model that is not an output parameter will be deleted. You do not have to explicitly set model variables as intermediate as you do when running model tools in ArcGIS for Desktop.
Writing output data to in_memory
One technique you can use to increase performance is to write intermediate and output data to the in_memory workspace.
Do not write output datasets to in_memory if you plan on configuring your service so that your output data is drawn by a map service.
When you use result map services, it is important to realize that there are two services—the geoprocessing service and the map service. These two services execute independently of each other. When the task executes, ArcGIS Server executes the geoprocessing task first, then executes the map service to draw the output of the geoprocessing task. Because of this execution order, the result map service needs datasets on disk produced by the geoprocessing task. This means that the output of the tasks in the geoprocessing service must be datasets on disk, not in_memory datasets.
Differences between 10.0 and later versions
If you authored geoprocessing services in 10.0, there were specific ModelBuilder techniques you used to author services, noted below. You no longer need to use these techniques in 10.1 and later versions.
Prior to 10.1, geoprocessing tasks were required to have Feature Set data types to input features in geoprocessing tasks, and Record Sets to input tables. You do not need to use feature sets or record sets for services at 10.1 and later versions; you need only specify an Input mode of User defined value for an input feature or table parameter when editing the task in the Service Editor. If your model (or script) currently uses a Feature Set or Record Set, you don't have to change it; it will publish as is.
Prior to 10.1, you had to explicitly set intermediate data variables in ModelBuilder and it was strongly recommended that all output be written to the geoprocessing scratchworkspace environment using the convention of %scratchworkspace% in the output path. It is no longer required that you use this convention.
Getting started with ModelBuilder
If you are unfamiliar with ModelBuilder, the table below lists a few topics that will help you get started writing models.
Basic concepts of creating your own geoprocessing tools.
These three topics introduce ModelBuilder.
This tutorial shows the basics of connecting tools and data together in ModelBuilder to create a model.
This tutorial shows the basics of creating a tool with ModelBuilder. A model tool is a model that exposes variables as parameters that appear on the tool dialog box when the model is run as a tool. You need parameters in order to create tasks. The other two topics show how to create model parameters.
You can create your own choice lists for model variables using value list filters. Choice lists are a great way to present options (choices) to clients of your task.
This topic introduces you to advanced techniques that you may have cause to use when authoring your task with ModelBuilder.