#NEWLINE# def stack_bands( filenames ) : #NEWLINE# #INDENT# 'Returns a 3D array containing all band data from all files.' #NEWLINE# bands = [ ] #NEWLINE# for fn in filenames : #NEWLINE# #INDENT# ds = gdal . Open ( fn ) #NEWLINE# for i in range ( 1 , ( fn . RasterCount + 1 ) ) : #NEWLINE# #INDENT# bands . append ( ds . GetRasterBand ( i ) . ReadAsArray ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# return np . dstack ( bands )