I have seen many questions about how to extract a singe band from a multiband raster in ArcGIS, but how do you extract ALL of the bands and save them as separate tifs? I want to automate this process using Arcpy because I have many bands in one multiband raster. I also want to be able to do a batch import to separate bands from multiple multiband rasters.
I'm guessing I can use CopyRaster, but I'm not sure how to use it when I need to make copies of everything!
import arcpy import os from arcpy.sa import Raster #setup workspace arcpy.env.workspace = "Y:\Commons\Kelly_Carly_Aaron_Project\lvl 3\OLCI-Sentinel3\Florida" arcpy.env.overwriteOutput= True #setup output directory out_dir= "Y://Personal//crobbins//Final_Project//Separate_bands_results//" #list all rasters in workspace RasterList = arcpy.ListRasters() #get list of bands from a multiband raster def list_bands(raster_workspace): raster_workspace = arcpy.env.workspace RasterList = arcpy.ListRasters() bands = [Raster(os.path.join(raster_workspace, b)) for b in RasterList] print bands list_bands("Y:\\Commons\\Kelly_Carly_Aaron_Project\\lvl 3\\OLCI-Sentinel3//Florida\\Copy_of_2017.0527.tif\\")
This doesn't work. It just lists the names of all the multiband tiffs I have in Y:\Commons\Kelly_Carly_Aaron_Project\lvl 3\OLCI-Sentinel3\Florida.