Tools that honor the Scratch Workspace environment use the specified location as the default workspace for output datasets. The scratch workspace is intended for output data you do not want to maintain.
The primary purpose of the Scratch Workspace environment is for use in ModelBuilder or Python.
- In ArcGIS Pro, the default value for the Scratch Workspace and Current Workspace environments is the project default geodatabase.
- When using the Geoprocessing pane, output dataset names are automatically generated using the Current Workspace and Scratch Workspace environments. The logic for generating the output name is as follows:
- If the Scratch Workspace environment is set, the automatically generated output path will be the scratch workspace.
- If the Scratch Workspace environment is not set, the current workspace environment is examined. If the current workspace is set, the automatically generated output will be the current workspace.
- If neither the Scratch Workspace nor the Current Workspace environment is set, the automatically generated output path will be the workspace of one of the inputs. In this case, certain restrictions apply. For example, the workspace may not have write access. In some cases, the output will be written to the system temp directory.
- If you provide a base name for the output dataset, the Current Workspace environment will be used to construct the output path, regardless of whether the Scratch Workspace environment is set.
- Scratch Workspace—The workspace where tool outputs will be placed if the default output name is used
arcpy.env.scratchWorkspace = path
The default location for geoprocessing tool input and output.
# Set the scratchWorkspace environment to local file geodatabase
arcpy.env.scratchWorkspace = 'c:/data/scratchoutput.gdb'