Select to view content in your preferred language

ModelBuilder: renaming of raster files during iterative model run

5707
6
04-23-2013 12:34 PM
DanBlythe
Emerging Contributor
I am using an iterative model to run a set of raster files (as list variables) through several tools, namely:
1. define projection
2. build attribute table
3. clip
4. project raster
5. resample
6. clip
7. calculate statistics

When the model reaches step 4 (Project Raster), it fails to execute. I identified the problem as being the numeric characters at the beginning of each filename in the intermediate dataset between steps 3 and 4; that is, the filenames that are output from step 3 (Clip) all begin with a number (e.g. 01_Clip.tif, 02_Clip.tip, 03_Clip.tif, etc.). These filenames were automatically generated by Model Builder when I built the model.

To remedy the problem, I manually changed each filename in that intermediate dataset, such that they end with a number (e.g. Clip_01.tif, Clip_02.tif, Clip_03.tif, etc.). However, as soon as I ran the model again, those filenames defaulted back to their original format, and the same problem occurred at step 4.

I am unsure of how to control the filenames if Model Builder automatically generates an unacceptable format at the start of each model run. Any suggestions would be greatly appreciated.
0 Kudos
6 Replies
JeffreySwain
Esri Regular Contributor
Consider the use of inline variables to modify and harvest the name of the raster.  Perhaps using the Calculate Value tool in Model Builder to modify it if necessary.
0 Kudos
AlisonSchilling
Regular Contributor
Can you send a graphic of your model and what projection you are defining and what projection you are projecting to. I re-created the tools in a model and mine fails at that step also. I will get back to you soon.

After playing a bit with my model, first I do not set anything to intermediate, I send all my data that I do not want to keep to a temp folder - this way I can view it if i want and keep it if I want or delete it. Next, projecting data should be done as soon as possible, so if you can I would define projection build attirubutes then reproject. My model above failed because the  project raster tool is not reading the current projection so it fails. As soon as I 'break' the model at clip and use the clip output as the input to project raster there is no longer a problem.
0 Kudos
curtvprice
MVP Esteemed Contributor
If you construct a an intermediate filename using a built-in variables, the system won't modify them when the model is validated. (Note, %scratchfolder% is 10.1 only, %scratchworkspace% would be used in earlier versions).

For example:

%scratchfolder%\clip_%n%.tif

will be interpreted at runtime as

D:\work\scratch\clip_0.tif
D:\work\scratch\clip_1.tif
...


Depending on the iteration, the built-in iteration variable used could be either %n% or %i%.

Hope this helps!
0 Kudos
JulieButler
New Contributor
Hi Curt,

Thanks for your suggestion. Unfotunately, it does not work. I specified %scratchworkspace% as the Clip-output filename (I'm using 10.0), but the filenames default to the original problematic formatting (01_Clip.tif, 02_Clip.tif, etc.) as soon as I validate or run the model. I tried a similar approach yesterday by inserting a string variable names "scratch" and specifing "%scratch%" as a prefix to each filename. The same problem occured, however.

This seems as though it may be a bug within the version of Model Builder that I'm using. I'm surprised by how difficult it is to control the filename of intermediate datasets. 

If you construct a an intermediate filename using a built-in variables, the system won't modify them when the model is validated. (Note, %scratchfolder% is 10.1 only, %scratchworkspace% would be used in earlier versions).

For example:

%scratchfolder%\clip_%n%.tif

will be interpreted at runtime as

D:\work\scratch\clip_0.tif
D:\work\scratch\clip_1.tif
...


Depending on the iteration, the built-in iteration variable used could be either %n% or %i%.

Hope this helps!
0 Kudos
PoojaPandey1
Deactivated User

Hi Julie

I am using model builder to rename different dbf tables name, for the same using rename tool using inline variable %n%. The names are changed what I wish to do is instead of starting the series from 0, start it from 1, is it possible?

0 Kudos
curtvprice
MVP Esteemed Contributor
What is your ArcGIS version and SP? (See Help > About ArcMap) If not on the most recent, do update!
0 Kudos