Scratch GDB (Environment setting)

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

Writing output to the scratch geodatabase will make your code portable, as this geodatabase will always be available or created at execution time.

Usage notes

  • The scratch geodatabase 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.
    • If the Scratch Workspace environment has been set, the Scratch GDB environment will reflect this value first.
      • If your Scratch Workspace environment references a geodatabase, the Scratch GDB and Scratch Workspace environments will point to the same paths.
      • If your Scratch Workspace environment points to a folder, the Scratch GDB environment will look for a geodatabase in the folder named scratch.
    • If the Scratch Workspace environment has not been set, the Scratch GDB environment defaults to a geodatabase within the AppData section of the User Profile, typically C:\Users\<user_name>\AppData\Local\Temp\1\scratch.gdb.
  • Data written to the Scratch GDB environment is not automatically deleted. You must do your own cleanup.

Dialog syntax

Note:

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

Scripting syntax

arcpy.env.scratchGDB

Script example

import arcpy

print(arcpy.env.scratchGDB)

Related topics