4

I am trying to create a model in ModelBuilder (ArcMap 10.2.2), where there is an iteration through rasters in a workspace, each raster is run through a formula in raster calculator and where the output name is dependent on the raster name. As you can see in the picture, I have put an invariable output name %Name%, which should change with each iteration, with a new name coming from the new raster. This does not work however, only the first two iterations change the name, then all following iterations uses the first created namespace.

E.g.: If the raster file names are 'a' through 'c', the model will create raster a and b and then overwrite all following raster onto 'a' namespace, overwriting the data.

I have also tried using the %n% and %i% variables, with the same result.

I have put all rasters in a workspace (geodatabase) that is another than the the currently active one, using ArcCatalog Import-->Raster Datasets... in ArcMap window. The raster file names does only have text and numbers, no spaces or special characters.

Faulty model Model created in the ArcMap modelbuilder. There are so many arrows pointing to raster calculator because their values are used multiple times in the formula

Add.The problem with the model is that the generic variable "Workspace" don't work this way, see solution below

This post seems to have a somewhat similar problem, although it has not been resolved: Why does inline variable output overwrite occurs with Reorder fields tool?

  • I have also tried to set 'Name' as a precondition for Raster calculator.
  • I have been trying both running raster sets from Workspace (default and other geodatabase (gdb)) and from a Raster catalog, same results.
  • This happens even if I use other tools such as Clip, with Workspace as input for rasters.

I am using the following paths:

input: E:\kaosmapp\Magdalena Bulks\NDVI calc\NDVI_images or E:\kaosmapp\Magdalena Bulks\NDVI calc\NDVI_calc.gdb (tried both)

output: E:\kaosmapp\Magdalena Bulks\NDVI calc\output\%Name%.tif

It gives the same result regardless if I add .tif or not for output file.

  • Two tricks: 1.Make sure you use the correct case for the inline variable - here %Name% and not %name% - this seems to be OK from your screenshot - 2. Try setting 'Name' as precondition for the Raster Calculator tool. I've had such issues with 10.0, don't know if they still occur in 10.2. – GISGe Jan 7 '16 at 12:48
  • Thank you for your comment. Sadly, it did not do the trick. I made sure the I was using %Name% and also tried %i% and %n% namespaces and tried adding precondition of 'Name'. After that I also tried adding precondition of 'Raster' and 'Workspace'. Still the same problem, file 'a' and file 'b' are created, then all files are written to 'a' – Rasmus Gustafsson Jan 7 '16 at 19:04
  • Can you edit your question to show us what your raster calculator expression is? – Hornbydd Jan 7 '16 at 21:16
  • Hi Hornbydd, This happens regardless of the raster calculator expression (for example ' "Raster"+1' ) and even with other tools such as e.g. Clip. – Rasmus Gustafsson Jan 7 '16 at 21:53
  • Ok, show us what the full paths are for your inputs and outputs. – Hornbydd Jan 7 '16 at 21:59
2

This answer (by the asker) has been moved from within the question to conform to the Q&A format of this site.


To make the iteration work, I had to create a geodatabase and import all rasters I wanted to manipulate. Then I could click''n'drag the gdb into the model. By setting the gdb as a 'Model parameter' the model can be feeded with any other geodatabase and saved into any folder or geodatabase.

However, if a generic variable 'Workspace' is created, linked to an iteration and then feeded with the same geodatabase, my problem described above will occur.

Working model Working model with geodatabase click'n'dragged into model

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.