简体   繁体   中英

How to find the number of bands in gdal in python?

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?

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM