I have a large collection of single-band geotiffs (NIR, Green, and Red) that I would like to composite using a Python script. The goal is to iterate through multiple folders in a main directory, identify each tiff as band1, band2, band3 to input into CompositeBands_management, and do this for every raster scene. To clarify, each image number, i.e. scene, has three single-band tiffs associated. For example, the naming convention is: TTC2500_Green_Channel_8.TIF where TTC2500 is the image number.
So far, my script can go through each folder and identify the specific bands based on the filename but I am having difficulty bringing them into the tool. The attached script has the Composite tool commented out but the result is a printed list of each geotiff. Any thoughts on how to move from here into an automated processing method to output new false color composite geotiffs?
import arcpy import os from arcpy.sa import * from arcpy import env env.workspace=(r"C:\Users\cc\Desktop\tcamPractice") env.overwriteOutput = True outws=(r"C:\Users\cc\Desktop\tcamPractice\false") folders=arcpy.ListWorkspaces() for root, dirs, files in os.walk(r"C:\Users\cc\Desktop\tcamPractice"): for raster in files: rasterlist=arcpy.ListRasters("*", "TIF") outraster=outws+"comp.tif" if raster.find("Green")>0: band1=raster print band1 elif raster.find("Red")>0: band2=raster print band2 elif raster.find("Nir")>0: band3=raster print band3 #arcpy.CompositeBands_management([[band3;band2;band1]], outraster)