AnsweredAssumed Answered

Help: Batch - composite bands  Arc-python

Question asked by zia207 on Aug 5, 2015
Latest reply on Aug 6, 2015 by xander_bakker
Branched to a new discussion

Dear All,

I am trying to make  a composite band of six raster files. I have do this for  +40 scenes of Landsat 8 processed data. Each scene folder contains about +12 tif files, I want create multi-tif file with  following bands using Arc-python batch mode:


LC81360432015069LGN00_toa_band2.tif# Blue
LC81360432015069LGN00_toa_band3.tif"# Green 
LC81360432015069LGN00_toa_band4.tif"# Red 
LC81360432015069LGN00_toa_band5.tif"# NIR
LC81360432015069LGN00_toa_band6.tif# SWIR 1 
LC81360432015069LGN00_toa_band7.tif"# SWIR 2 





The following python script works fine when the folder  contains only above six files. For this, I have to  reorganize all 40 folders accordingly,  I do not want to do this. This there any way to create a file list only with above six files? Help will be appreciated. Thanks




import arcpy, os

arcpy.env.workspace = r'E:\Landsat8\Process_data_2015\'

# list all folders in a directory

folders = arcpy.ListWorkspaces()

for folder in folders:

    arcpy.env.workspace = folder

    rasters = arcpy.ListRasters("*.tif")

    name = os.path.join(rasters[1].split("_")[0] + ".tif")

    arcpy.CompositeBands_management(rasters, name)

print "Processing complete"