I have a problem for apply this function in all files. This script is about the extraction of the bands from a raster and I want to use it on all the file raster in the folder. It works on the single file but I can not apply to all files from the folder.
import glob, os, processing from osgeo import gdal in_path="C:/.../folder_input/" out_path ="C:/.../folder_output/" file_list = os.listdir(path) file_list= [file for file in os.listdir(path) if os.path.splitext(file) == '.ecw'] for file in file_list: print (file) src_ds = gdal.Open(file) for file in range (1,file.RasterCount+1): out_ds = gdal.Translate(out_path + '1' + str(file) + 'ecw',src_ds, format='GTiff', bandList=[i]) out_ds=None
AttributeError: 'str' object has no attribute 'RasterCount'