7

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 Overview

However, If I run it with a geodatabase workspace, I get an error (below).

Error

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.

Contour Tool

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.

2

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.

2

I've run into a similar problem with models not wanting to run even if everything is perfect. You'll probably need to either set up dummy files or set dummy—but valid—default values for all the inputs that show up in white. Once all the inputs are showing some sort of color you can save the tool, run it, then change the inputs to what they're supposed to be.

Also, if you're dealing with a raster and have—or can create—some sort of polygon in the shape or the area you want extracted, you can use Extract By Mask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.