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.
The primary purpose for the Scratch Workspace environment is for use in ModelBuilder or Python scripting.
Learn more about using the current and scratch workspace environments.
Usage notes
- In ArcMap, the Scratch Workspace and Current Workspace environments are synchronized by default to the map document's default geodatabase. To learn more, see Setting the default geodatabase.
- In ArcCatalog, the Scratch Workspace and Current Workspace environments are not set by default.
- As implied by the name, the Scratch Workspace environment is intended for output data you do not wish to maintain.
- When using the tool dialog box, output dataset names are autogenerated using the current and scratch workspace settings. The logic for generating the output name is as follows:
- If the scratch workspace environment is set, the autogenerated output path will be the scratch workspace.
- If the scratch workspace environment is not set, the current workspace environment is examined. If current workspace is set, the autogenerated output will be the current workspace.
- If neither the scratch or current workspace is set, the autogenerated output path will be the workspace of one of the inputs. In this case, certain restrictions apply. For example, if the workspace is a coverage workspace and the output is a new feature class, the output will be a shapefile to the directory above the coverage workspace. There are other restrictions as well, such as write access. In some cases, the output will be written to the system temp directory.
- If you enter a base name for the output dataset, the current workspace will be used to construct the output path, regardless of whether the scratch workspace is set.
Dialog syntax
- Scratch Workspace—The workspace where tool outputs will be placed if the default output name is used
Scripting syntax
arcpy.env.scratchWorkspace = path
Parameter | Explanation |
---|---|
path | The default location for geoprocessing tool input and output. |
Script example
import arcpy
# Set the scratchWorkspace environment to local file geodatabase
arcpy.env.scratchWorkspace = "c:/data/scratchoutput.gdb"