8

i'm read tiff data using under code.

ds = 'path' , gdal.GA_ReadOnly)

and i find gdal API, i cna't find to read number of bands.

(ex) i have a 3 bands image, then read number of bands and return 3 in case)

is a any way to find number of bands?

송준석
  • 991
  • 1
  • 16
  • 32

1 Answers1

16

The RasterCount attribute gives the band count. Here's a simple example:

src_ds = gdal.Open("INPUT.tif")
if src_ds is not None: 
    print ("band count: " + str(src_ds.RasterCount))
Eran
  • 2,324
  • 3
  • 22
  • 27