Iterate through rasters in a folder and Copy to another folder

2102
3
11-15-2011 10:24 PM
MagnusRydén
New Contributor
Hi!

I´m using modelbuilder as a part of a multi criteria evaluation. One part of the process is to rasterize all polygon featureclasses in a folder and copy them to another.  See the attached image.
But i always get the 99999 Error. When the folder variable is set. The tools color up and are ready to run but it still won´t work. Maybe I missed how the iterate raster is supposed to be used?
The rasterize process is already done. All that is needed is to Copy the rasters to another folder.
/Magnus
0 Kudos
3 Replies
ChristopherThompson
Regular Contributor
I think part of the problem may be with using the parse path tool.  The 'name' generated from the iterate tool doesn't actually create a pathname, it only creates a variable that holds the file name, so the parse path tool is probably creating nothing.

I've attached a image of a model that essentially does the same thing as yours, though it prompts the user to supply the name of a new folder, which it creates under the folder containing the raster data. If you needed the output folder in some other location alltogether you could give another parameter specifying the root directory for a new folder to get created in.

You have to use inline variables to string together the output folder name along with the raster name to create the raster dataset in this implementation.
0 Kudos
ChristopherThompson
Regular Contributor
One more thing, in thinking about how you describe your process where you say "One part of the process is to rasterize all polygon featureclasses in a folder and copy them to another" - you might consider having the Polygon to Raster tool simply create the output where you need them to go. This would eliminate the need to run another process against the same data which can be time consuming depending on the size of your rasters and how many there are.  Of course, you may need two copies of the raster datasets.
0 Kudos
MagnusRydén
New Contributor
Thanks for the help!

Your method seem to work. I´did solve it another way however  just before this reply by using a GDB folder which is created as a part of a previous model. Then it works exactly as if i would have specified a folder.  Not really sure why. About the copies I didn´t relly need two of them but the model in the picture was a result of me getting strange errors when iterating Features and Creating rasters and at the same time specify a subfolder to place the result. When specifying the same folder to place the result in, it worked strangely...
0 Kudos