How can I add a work space to Model builder?

3925
3
08-14-2017 02:34 PM
AndrewMartin8
New Contributor III

I am trying to create a model builder and it creates various raster's while it runs. I want to have the option to pick what folder I want to save every thing in. Having the set up something like this.

In the model builder I want the workspace to be connected to every raster output. It gives me the option to make this the "current workspace" when I try to connect it but the arrow does not stick with it. I have the arrows set to precondition.

Is there anyway I can get around this? I want to be able to use this model builder on multiple map documents but with different folders where the layers will go.

0 Kudos
3 Replies
ChrisDonohue__GISP
MVP Alum

A couple of ideas to play with:

One possibility is to use an In-line Variable Substitution:  (See Example #1 in the link)

Examples of inline model variable substitution—Help | ArcGIS for Desktop 

Another possibility is to use the Modelbuilder Environments:

  • With the model open in Edit Mode, click on the word "Model" on the top left, then Model Properties..., Environments Tab, then in the list hit the plus sign next to Workspace to expand the listings.  Then put a check in the one you want to modify and hit the "Values" button. On the window that comes up, click on the word "Workspace" in the left to open a place where you can browse for the workspace.

Also, if the issue is that you want the tool user to be able to browse to a different workspace each time the tool is run instead of it being set to the same workspace all the time (ie instead of "hard-coded"), you can set up Modelbuilder so the Parameter is Exposed.  If this is done, the tool will require the user to supply the location of the workspace each time it is run.

Exposing tool parameters as variables—Help | ArcGIS for Desktop 

Chris Donohue, GISP

AndrewMartin8
New Contributor III

So the In-Line Variable Substitution works great! but after the Model Builder is executed it delete the previous raster and only gives me the raster it created. How can I prevent it from deleting the previous rasters from the folder when it completes the raster builder?

0 Kudos
ChrisDonohue__GISP
MVP Alum

Solutions to this depend on which rasters are being deleted - the final outputs or the intermediate files:

  • If the rasters that are being deleted are the ones created along the way as part of the processing ("intermediates") and you want to keep them, one can arrange to have them retained in a few different ways.  Check out this topic to get a feel for how Modelbuilder handle file retention and some methods of keeping the intermediate files from being deleted:

A quick tour of managing intermediate data—Help | ArcGIS for Desktop 

  • If the rasters being deleted are the final output, that issue can often be resolved by giving each final output an unique output filename (which differ from the input file names and other output file names).  In-line model variable substitution can be put to use here as one way to provide distinct file names  (See Example #2 in link below):

Examples of inline model variable substitution—Help | ArcGIS for Desktop 

Chris Donohue, GISP