Monday, October 5, 2015

Came across a way to pull out one raster from a multiband in Modelbuilder

Sometimes it is nice to have a quick and simple way of pulling out the single bands from a multi-band image stack without having to resort to a python script.  This stack exchange post shows how to do it in a nice, easy, and straightforward manner in ArcGIS ModelBuilder. Kudos to xyz for coming up with this answer. I was able to use this approach recently to perform principal component analysis and then continue to work with the raster downstream.


In this example the parse path tool is used to pull out the path and file name. Then Band_1 is appended in the output name of the raster calculator using the following function: "%Path%\%File%\Band_1"*1

3 comments:

  1. %Path% can be substituted with %Input Workspace% for similar tools.

    ReplyDelete
  2. We can also add the Calculate Value tool with a statement like str("%Name%").replace("vegetation", "tree") and data type as string if we want to sub out base names. Syntax is important. Make sure that it is a string first.

    ReplyDelete
  3. and str("%Name%")[4:8] if we want to keep characters 4 - 8 from the name. This works well if all of the rasters have the same number of characters in their name.

    ReplyDelete