Setting Current and Scratch Workspace environments
Tools that honor the Current Workspace environment setting use the workspace specified as the default location for geoprocessing tool inputs and outputs.
Tools that honor the Scratch Workspace environment setting use the specified location as the default workspace for output datasets. The Scratch Workspace is intended for output data you do not wish to maintain.
Using the Current and Scratch Workspace environments
Most tools will automatically set an output value or path once values are specified for the input parameters. When the Current or Scratch Workspace is set, the output path that is automatically generated will default to the location set in the Current or Scratch Workspace.
Special consideration must be made in choosing to use a Current or Scratch Workspace. Workspace environment settings have different impacts depending on which environment workspace is specified:
- If the Scratch Workspace environment is specified, all tools will use this path to generate output paths.
- If the Current Workspace environment is specified, and the Scratch Workspace is not specified, all tools will use the Current Workspace to generate output paths.
- If both the Scratch and Current Workspace environments are not specified, tools will generate an output path based on the path of the first input dataset.
- If both the Scratch and Current Workspace environments are not specified and the location of the first tool input is read-only, output will be written to the system's temp directory.
The output path that is autogenerated by a tool can always be manually changed. Either open the tool dialog box and enter a new output path or open the variable in ModelBuilder and enter a new path.
Setting Current and Scratch Workspace environments at the model level
It is recommended to set the workspace environments at the application level instead of at the model level, especially if the model will be shared or run from the model tool dialog box. When workspace environments are hardcoded within models, there is a greater risk for error when the model is shared because the hardcoded workspace path may no longer exist or be accessible.
-
In the Catalog window or ArcToolbox window, right-click the model tool and click Properties. Or do one of the following:
- In the ModelBuilder menu, click Model > Model Properties.
- Right-click anywhere on the model diagram and click Model Properties.
- Click the Environment tab.
- Expand the Workspace settings.
- Check the Current Workspace and Scratch Workspace setting and click Values.
- In the Environment Setting window, navigate to the workspace that you want to use as your current and scratch workspace for the model.
- Click OK.
Using Scratch Workspace in a model
Once a Scratch Workspace is set, this workspace can be used to easily create and manage outputs.
In the following example, the Scratch Workspace environment is set to C:\Scratch\Scratch.gdb, a file geodatabase where all output datasets can be written to.
- Double-click a tool in a model to open its tool dialog box.
-
To define the output, use the output location %scratchworkspace% to automatically write the tool output to the location specified in the Scratch Workspace environment.
%scratchworkspace% is used as an in-line variable, which is replaced by C:\Scratch\Scratch.gdb (the Scratch Workspace environment setting) when the tool is run.