As we know sentinel satellite data have many sub folder. I want to create composite band of each datasets with the band 2, band 3, band 4, band 8 which are located in one folder(10m) and band 11, band 12 which are located in other folder(20m).I am making a arcpy code for that but code was not run correctly. Here is the code
import arcpy, os
#arcpy.env.workspace = "L:\Arcpy\Data\Satellite_image_raw\New folder"
basepath = "L:\Arcpy\Data\Satellite_image_raw\New folder"
endswith = ("_B02_10m.jp2", "_B03_10m.jp2", "_B04_10m.jp2", "_B08_10m.jp2", "_B11_20m.jp2", "_B12_20m.jp2")
output = "L:\Arcpy\Data\Layer_stack"
rasterlist = []
#folders = arcpy.ListWorkspaces()
#for folder in folders:
#arcpy.env.workspace = folder
for root, dirs, files in os.walk(basepath):
for rasterlayer in files:
if rasterlayer.endswith(endswith):
#print(os.path.join(root, rasterlayer))
rasterlist.append(rasterlayer)
print "image:" + str(rasterlist)
name = os.path.join(output, rasterlist[1].split("_")[0] + ".img")
arcpy.CompositeBands_management(rasterlist, name)
print(rasterlist)