# Import system modules import sys, string, os, arcpy arcpy.env.workspace = "H:/" tifList = arcpy.ListRasters("*.tif") for inTIFF in tifList: print inTIFF outTIFF = "E:/Rasters/NAIP2009/" + inTIFF # Create a value table to hold the multivalue parameters for the Union_analysis vtab = arcpy.CreateObject("ValueTable") vtab.addRow(inTIFF + "\\Band_1") vtab.addRow(inTIFF + "\\Band_2") vtab.addRow(inTIFF + "\\Band_3") # Process: Composite Bands... print "Composite Bands 1 2 3 " + str(inTIFF) arcpy.CompositeBands_management(vtab, outTIFF)
I have been trying to get the raster iterator to work but i cannot get it to maintain the original file name. Script or model, either way it works, will work for me.
# Import system modules import sys, string, os, arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create() # Load required toolboxes... gp.AddToolbox("C:/\Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") gp.workspace = "E:/Temp/FourBandNAIP" tifList = gp.ListRasters("*") inTIFF = tifList.Next() while inTIFF: outTIFF = "E:/Rasters/NAIP2009/" + inTIFF if gp.exists(outTIFF): print "Skipping " + str(inTIFF) else: # Create a value table to hold the multivalue parameters for the Union_analysis vtab = gp.CreateObject("ValueTable") vtab.AddRow(inTIFF + "\\Band_1") vtab.AddRow(inTIFF + "\\Band_2") vtab.AddRow(inTIFF + "\\Band_3") # Process: Composite Bands... print "Composite Bands 1 2 3 " + str(inTIFF) gp.CompositeBands_management(vtab, outTIFF) inTIFF = tifList.Next() del gp
You could create a model that uses the Make Raster Layer tool and then the Copy Raster tool to remove the 4th band.The Make Raster Layer tool allows you to specify the input bands. In your case, 1,2,3.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.