3

I have digital elevation models clipped to watershed boundaries and I have to run a set of tools to hydrologically condition each one, and I want to use the iterator tool to automate this process.

Each DEM starts in a unique folder with the HUC 10 code, and each time I run the model, I want all the outputs to go into the unique folder that the DEM started in. Then, when the model iterates through to the next DEM, I want all of those output files to go in that unique folder. I have the recursive option in the iterator parameters checked so it will iterate through each subfolder, but I am having trouble figuring out how to set up the output so that each output file goes into the same folder that the original input came from.

enter image description here

Is there some sort of coding that I need to put in the output name for each tool? Something along the lines of %____%DEMfel.tif? I'm familiar with %n% and %scratchworkspace% but those don't work for me because it puts all the output files into one single folder.

I tried referring to this post, but that did not work for me: Iterating in ModelBuilder to Generate Output Files in Source Folder?

3

You want to be using the Parse Path tool which is a model only tool like the iterator. You pass in the raster and can extract out the path to it, which would give you the location you want write back into. See example as shown below.

Model showing Parse Path tool

You would make the output of Parse Path a precondition to your Pit Removal tool to ensure that it runs before the rest of your workflow.

4

I am not sure if it matters to keep the current file structure the way it sits. However, if you do not need to maintain file schema integrity you could get away with creating a stand-alone variable and setting it to your workspace (e.g. C:\0207000_test).enter image description here - Rename the "Any Value" to "%Data Workspace%"

Then use the Create Folder function and set the variables to be %Data Workspace%enter image description here You could apply the model above just before the Pit Remove function in your model and it should be able to iterate through fine.

there are some good examples of Inline Variable Substitution on ESRI's Website:

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.