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 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 the Scratch Workspace environment references a geodatabase, the Scratch GDB environment will be set to a geodatabase named scratch.gdb in the same folder as the Scratch Workspace environment.
      • If the Scratch Workspace environment references a folder, the Scratch GDB environment will be set to a geodatabase named scratch.gdb in that folder.
    • If the Scratch Workspace environment has not been set, the Scratch GDB environment will be set to a geodatabase in the AppData section of the User Profile, typically C:\Users\<user_name>\AppData\Local\Temp\1\scratch.gdb.
  • If the scratch geodatabase does not exist, it will be created when the arcpy.env.scratchGDB environment is called.
  • Data written to the Scratch GDB environment is not deleted upon the completion of a script. You must delete it manually.

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