Modelbuilder Workspaces: Defaults to a folder, would like it to be a geodatabase

3954
3
10-14-2014 07:59 AM
SeanO_Brien
New Contributor III

I'm having an issue with modelbuilder workspaces. I have created a simple model to clip a raster, run focal statistics on it, and create contours. I have a workspace variable as an input. If I run the tool with a folder as a workspace, it works just fine. (Overall model is attached as "Overview")

However, If I run it with a geodatabase workspace, I get an error (see "Error" attachment)

I know what is causing the error. Within the Contour tool in modelbuilder, the output is set to add the ".shp" suffix (see "Contour Tool" attachment below). When I try to delete the ".shp", it automatically populates it in the output once I click apply or ok. I assume modelbuilder defaults a workspace to be a folder.

So I have two workarounds-

  1. I can use a folder workspace. I'd prefer to run this tool in a geodatabase because rasters take up less space and perform much better in a .gdb. This is especially useful if a bigger area is being processed.
  2. I can pre-populate the Workspace variable with a dummy geodatabase and have that be the default input. When I do this, I am able to delete the .shp suffix in the Contour tool, and it will run. In a perfect world, I would just rather have it blank for the user.

I suppose I'm wondering if it's possible to leave the workspace area blank, and use a geodatabase as a workspace.

0 Kudos
3 Replies
curtvprice
MVP Esteemed Contributor

There is a built-in model builder variable: %scratchFolder% and %scratchGDB%. These are set up to allow you to force the use of a folder or geodatabase for intermediate datasets, whether the current workspace is a folder or GDB.

I don't think it is that obvious that file GDBs being the best place to store rasters. I think it really varies a lot depending on the tool being used and how big the dataset is. Temporary rasters created using arcpy map algebra are always stored as grids (in the scratchFolder!). Personally I usually set the scratch and current workspace to a folder, but of course do whatever works with your processing flow. This way when I do an arcpy <raster>.save() all it has to do is rename the raster, not copying it (important if it's a big raster!).

ArcGIS 10.2 Help: ScratchFolder, ScratchGDB

0 Kudos
SeanO_Brien
New Contributor III

After playing around with it, it doesn't seem like I can override the location of the scratch geodatabase in my user folder. Even if I specify it in the tool dialog box, or alter the tool environment properties.

It's a good point about rasters in the scratch folder. However, saving storage space is a big deal for me. GDBs are just so much better when working with rasters that are multiple GBs large (as much as 70% smaller for me). It's also nice to not have a restriction on name length, which is useful when running an iterator that takes the name of the input and adds to it.

0 Kudos
curtvprice
MVP Esteemed Contributor

I wasn't suggesting using the environment, I was suggesting setting the name of the intermediate raster in your model to:

%scratchGDB%\tempRaster

If the current scratch workspace is a folder, a file gdb names "scratch.gdb" will be created in that folder.  Otherwise it will just use the current workspace.

0 Kudos