Iterate Raster in Model Builder with Raster Calculator

5257
5
07-22-2013 07:19 AM
DavidCampbell
New Contributor III
Hi All,

I have a function I want to apply to a raster. I have multiple rasters, each will need this function applied. Here is the function:

( 11.16 * Sin( FocalStatistics( "%Name%", NbrRectangle( 3, 3, ???CELL??? ), "MEAN", "" ) ) / ( 0.765 + 2.625 *  FocalStatistics( "%Name%", NbrRectangle( 3, 3, ???CELL??? ), "MEAN", "" ) ) ) / ( 11.16 * Sin( FocalStatistics( "%Name%", NbrRectangle( 3, 3, ???CELL??? ), "MEAN", "" ) ) / ( 0.765 + 2.625 *  FocalStatistics( "%Name%", NbrRectangle( 3, 3, ???CELL??? ), "MEAN", "" ) ) + 1 )

As you can tell I have instigated 'iterate rasters' to get the %Name% input. I have this function currently stored in raster calculator within model builder. When I try and run the tool it crashes out saying that the raster does not exist.....it exists so obviously I am referencing it wrong inside of raster calculator but i don't see where I am going wrong. I am running 10.1.

Any help would be appriceated.
0 Kudos
5 Replies
DavidCampbell
New Contributor III
I have it solved....... put the output from iterate rasters to the collect values model tool. Use the output of that as the input in the raster calculator. So pull %name% not from the iterate rasters but from collect values.
0 Kudos
PompierOlivier
New Contributor
Hello Careys,

Thanks for the "collect values" solution but i have an issue with it. Model builder doesn't allow me to pipe "Output value" of Collect values tool in Raster calculator. How did you make it work ?
Many thanks

Olivier
0 Kudos
curtvprice
MVP Esteemed Contributor
Hi All,

I have a function I want to apply to a raster. I have multiple rasters, each will need this function applied. Here is the function:

( 11.16 * Sin( FocalStatistics( "%Name%", NbrRectangle( 3, 3, �??CELL�?� ), "MEAN", "" ) ) /
  ( 0.765 + 2.625 *  FocalStatistics( "%Name%", NbrRectangle( 3, 3, "CELL" ), "MEAN", "" ) ) ) / 
  ( 11.16 * Sin( FocalStatistics( "%Name%", NbrRectangle( 3, 3, �??CELL�?� ), "MEAN", "" ) ) / 
  ( 0.765 + 2.625 *  FocalStatistics( "%Name%", NbrRectangle( 3, 3, �??CELL�?� ), "MEAN", "" ) ) + 1 )

As you can tell I have instigated 'iterate rasters' to get the %Name% input. I have this function currently stored in raster calculator within model builder. When I try and run the tool it crashes out saying that the raster does not exist.....it exists so obviously I am referencing it wrong inside of raster calculator but i don't see where I am going wrong. I am running 10.1.


I unchecked your answer suggesting the use of Collect Values because it is incorrect. The correct answer is to use the Output Raster output of Iterate Rasters (not Name).
0 Kudos
DavidAinley1
New Contributor

I'mn have a similar issue... by output raster do you mean the output of the iterator or is that a tool on its own?  I need to be able to select individual bands after many rasters have pulled into the model.

0 Kudos
curtvprice
MVP Esteemed Contributor

I mean the output of Iterate Raster.

Rather than pull multiple rasters into a model, it is usually much easier to go with the flow and process each raster in the iteration one at a time. You can select individual bands using the Select Data tool on each iteration.

I suggest starting a new, more specific thread if you want help with your workflow that involves extracting bands. Sounds complicated.

UPDATE: Never mind, I see you did: model builder to create NDVI

0 Kudos