Como sabemos, los datos de los satélites centinela tienen muchas subcarpetas. Quiero crear una banda compuesta de cada conjunto de datos con la banda 2, banda 3, banda 4, banda 8 que se encuentran en una carpeta (10m) y la banda 11, banda 12 que se encuentran en otra carpeta (20m). Aquí está el código
import arcpy, os
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 = []
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)
Yo estaba tratando de estos códigos, pero la salida no se crea. Dio este error:
image:['T45QVD_20210104T044201_B02_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2', n
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2',
'T44QRJ_20210102T045209_B12_20m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2',
'T44QRJ_20210102T045209_B12_20m.jp2', 'T45QUD_20210102T045209_B02_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2',
'T44QRJ_20210102T045209_B12_20m.jp2', 'T45QUD_20210102T045209_B02_10m.jp2',
'T45QUD_20210102T045209_B03_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2',
'T44QRJ_20210102T045209_B12_20m.jp2', 'T45QUD_20210102T045209_B02_10m.jp2',
'T45QUD_20210102T045209_B03_10m.jp2', 'T45QUD_20210102T045209_B04_10m.jp2']
image:['T45QVD_20210104T044201_B02_10m.jp2',
'T45QVD_20210104T044201_B03_10m.jp2', 'T45QVD_20210104T044201_B04_10m.jp2',
'T45QVD_20210104T044201_B08_10m.jp2', 'T45QVD_20210104T044201_B11_20m.jp2',
'T45QVD_20210104T044201_B12_20m.jp2', 'T44QRJ_20210102T045209_B02_10m.jp2',
'T44QRJ_20210102T045209_B03_10m.jp2', 'T44QRJ_20210102T045209_B04_10m.jp2',
'T44QRJ_20210102T045209_B08_10m.jp2', 'T44QRJ_20210102T045209_B11_20m.jp2',
'T44QRJ_20210102T045209_B12_20m.jp2', 'T45QUD_20210102T045209_B02_10m.jp2',
'T45QUD_20210102T045209_B03_10m.jp2', 'T45QUD_20210102T045209_B04_10m.jp2',
'T45QUD_20210102T045209_B08_10m.jp2']
Traceback (most recent call last):
File "L:\Arcpy\Py_script\composite_band_script_1.py", line 35, in <module>
arcpy.CompositeBands_management(rasterlist, name)
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py",
line 13647, in CompositeBands
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Rasters:
¿Cómo puedo solucionarlo?