Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Scratch Workspace?

$
0
0
I am writing a script and started reading through the docs for creating/setting a scratch workspace. So far, all I am getting out of it is that it is a place for temporal data and that it garantees that the scratch workspace will exist if the tool is to be ported. It will also default to the users temp directory which is definied in os when Arc was installed (or you have changed that location). Before I came across the documentation, I was doing this:

Code:

if arcpy.Exists(r"C:\GIS\temp_data.gdb"):
    arcpy.Delete_management(r"C:\GIS\temp_data.gdb")     

arcpy.CreateFileGDB_management(r"C:\GIS\temp_data.gdb")

Which seems to me that does the same thing as creating the scratch workspace but also satisfies clearing out the temp data (in my case, that's what I want)

So in a workflow, let's say I wanted:
  1. Clip some feature classes and send output to a temporary workspace
  2. Maybe do some analysis on the clipped data (areas of clipped polygons, buffering, summarizing fields, etc)
  3. Output analysis to a report (excel, word, pdf, etc)
  4. And then have the temp clipped data go away. In my case, the original feature classes are quite dynamic and change on a regular basis, so my report will be considered a "Snaphot in Time"

Can anyone enlighten me as to why I would use a scratch worksapce over this method? Does it speed up performace in some way?

Documentation here

Blog here

Viewing all articles
Browse latest Browse all 2485

Trending Articles