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.
Here is the model
However, If I run it with a geodatabase workspace, I get an error (below).
I know what is causing the error. Within the Contour tool in modelbuilder, the output is set to add the ".shp" suffix (see 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-
-
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.
-
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.
Best Answer
Quick and dirty way of achieving this is to first make "Contour Output" a managed output (i.e., it will be generated in any case as long as you have default/scratch workspace) or save this into a folder location and use Copy Features tool with the inline variables as you used in your "Contour Output". Obviously this one has an extra step but as I said it is quick and dirty. I have not tried it yet but proper way of doing this could be adding a "Calculate Value" tool where there is Describe function (by workspaceType in Workspace properties) which produces a path for your data (whether folder or GDB) and you can feed this into "Contour" output.