2

I have a large number of rasters with 3 bands (R,G,B). What I want to do is add all 3 bands of each raster together to end up with a single band image with the summed R,G,B values in each pixel but I'm not sure how to do this in ModelBuilder.

If I have to somehow split each raster first, then add each one, then how would I iterate through each band of every raster?

This is what I have so far. Right now, it will take 3 bands of 1 raster and add the bands then go on to create a polygon of a certain reclassed area. I want to do this on a large number of rasters but am unsure of how to make it work.

enter image description here

0

4 Answers 4

3

Set up your model as shown below.

enter image description here

Tools used.

  • Iterate Rasters - Picks up all the rasters in a given workspace
  • Parse Path - Set Parse Type to PATH and FILE
  • Calculate Value - Calculates Full Path to Raster Band. Set Data Type as Raster Band. For Band 3 - the expression would be something like this "%path%"+"\%FILE%"+"\Band_3"
  • Composite Bands - Pulls out individual Bands using paths from Calculate value
  • Cell Statistics - Add the Bands together - Set Overlay Statistic to SUM
  • Add the rest of your processing steps
0
1

I believe this is the solution to the issue of "stacking" layers or raster bands for multiple images. This model is set up using standard NAIP imagery so red=1, green=2, blue=3, NIR=4. In this example, I am taking only the three color bands from the original image--combining them--then converting the format to PNG. My model uses the same concept as the first model at the top of this post, only simplified.

Use these from the above post:

Iterate Rasters - Picks up all the rasters in a given work space Parse Path - Set Parse Type to PATH and FILE Calculate Value - Calculates Full Path to Raster Band. Set Data Type as Raster Band. For Band 3 - the expression would be something like this "%path%"+"\%FILE%"+"\Band_3" Composite Bands - Pulls out individual Bands using paths from Calculate value

Remember:

  1. To put quotes on expression for each band, exactly how its typed above.
  2. The order in which you connect each band to the composite bands tool, is the order it is stacked in the image. (Use preconditions to order them.)
  3. The parse path connecting the iterator name to the output is to carry the original file name to the output. (The model won't work properly without the precondition to the composite bands tool)
  4. Also, for the Iterator Parse path, select Name for parse type, or the original file extension will be included in the output name.

enter image description here

1

This question and answer were helpful to me, but I couldn't get the answer model above to work for me (I got stuck around the issue of "what are the connections from parse path to calculate value..?" as did @eddie416). I ended up finding a simpler solution using the Select Data tool (model only), as below.

My task was slightly different in that I wanted to iterate through rasters and then calculate a statistic based on only band 2 out of the rasters. But the Select Data tool could be used repeatedly to select the various bands to feed into Cell Statistics (e.g. for the question above) or other tools. In my case I also had to use the Collect Values (model only) tool so that Cell Statistics could operate on each of the rasters being iterated.

model

0

I had the same trouble as another person connecting the Parse Paths to the Calculate Value.

Eventually I worked out that the connections from Parse Path to Calculate Value are Preconditions, not inputs. Once I got that, the model worked perfectly.

I also did this in ArcGIS Pro and it worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.