I'm attempting to automate the "Composite Bands" tool somehow in ModelBuilder, but haven't been able to figure out an effective method.
I have landsat 7 data that is separated into folders and each holds 7 bands (tif). Basically I want to generate a model or script that composites all bands in the raster output for each location, and then saves the result in a output folder.
I've prepared a ModelBuilder that take each band and save it in its correspondent folder. However, the input raster just read 1 band, not all 6 bands. Any Solutions, maybe Python?
ArcGIS Desktop – Loop in ModelBuilder for Compositing Bands of Multiple Images
arcgis-desktopcompositeiterationloopmodelbuilder
Best Answer
You mentioned that you are open to a Python solution, which is good because automating this process with Python is much easier and more flexible than a ModelBuilder approach.
First, import the necessary modules
Define the workspace that contains all of the folders with the Landsat imagery
Specify where you would like the output to go
List all of the workspaces in the previously defined workspace
Iterate through this list of workspaces and create a new list within each iteration of unstacked raster bands e.g.
['LC80260272014159LGN00_B1', 'LC80260272014159LGN00_B2',...]
Landsat files follows this form:
LC80260272014159LGN00_B1.tif
, so we need to strip off anything after the "_" and use the first basename as the output name. You can do this with various slicing methods and string manipulation in Python.The complete script: