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.

Learn more about Current WorkspaceLearn more about Scratch Workspace

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:

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

NoteNote:

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.

Steps:
  1. 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.
  2. Click the Environment tab.
  3. Expand the Workspace settings.
  4. Check the Current Workspace and Scratch Workspace setting and click Values.
  5. In the Environment Setting window, navigate to the workspace that you want to use as your current and scratch workspace for the model.
  6. 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.

Steps:
  1. Double-click a tool in a model to open its tool dialog box.
  2. To define the output, use the output location %scratchworkspace% to automatically write the tool output to the location specified in the Scratch Workspace environment.
    Setting scratch workspace using %scratchworkspace%

    %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.

Related Topics


9/13/2011