AnsweredAssumed Answered

Python Script to iterate numerous, single-band rasters for arcpy.CompositeBands

Question asked by cl_calamaio on Apr 14, 2015
Latest reply on Apr 16, 2015 by jskinner-esristaff

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 import *
from arcpy import env

env.overwriteOutput = True

for root, dirs, files in os.walk(r"C:\Users\cc\Desktop\tcamPractice\point1_tif"):
    for raster in files:
        rasterlist=arcpy.ListRasters("*", "TIF")
        if raster.find("Green")>0:
            print band1
        elif raster.find("Red")>0:
            print band2
        elif raster.find("Nir")>0:
            print band3
        arcpy.CompositeBands_management(raster, outraster)