Skip To Content

Scratch GDB (Environment setting)

The Scratch GDB environment setting is the location of a file geodatabase you can use to write temporary data.

The Scratch GDB environment complements the Scratch Workspace environment. Its primary purpose is for use by scripts and models as geoprocessing services, with the added focus of only pointing to a known geodatabase. When ArcGIS Server executes a geoprocessing task, the Scratch GDB is always available to write output to. This environment is also useful in authoring scripts and models for use on the desktop. Writing output to the Scratch GDB will make your tool portable because this location will always be available or created at execution time.

Usage notes

  • The Scratch GDB is guaranteed to exist when your script or model runs, and you will have write access to this geodatabase.
  • The Scratch GDB environment is read-only; you cannot set the location directly. The location is derived; the following points explain how.
    • If you have set the scratch workspace, or the map document has a scratch workspace set, the Scratch GDB will reflect this value first.
      • If your scratch workspace references a geodatabase, the Scratch GDB environment and scratch workspace will point to the same paths.
      • If your scratch workspace points to a folder, the Scratch GDB environment will look for a geodatabase in the folder named scratch.
    • If the scratch workspace has not been set, the Scratch GDB defaults to the current user's Documents directory. On Windows 7 and 8, this directory is C:\Users\<user>\Documents\ArcGIS. scratch.gdb will be created in this directory.
  • Data written to the Scratch GDB is not automatically deleted. You need to do your own cleanup.
  • The Scratch GDB can be used in your Python scripts. Make sure to set your Scratch Workspace variable prior to using it; this way, you know where the output will be generated.

Dialog syntax


The Scratch GDB environment is only available in Python and models.

Scripting syntax


Script example

import arcpy
arcpy.env.scratchWorkspace = 'c:/LandUse/ForestCover'

# c:\LandUse\ForestCover\scratch.gdb

Related topics