简体   繁体   English

如何在python中找到gdal中的band数?

[英]How to find the number of bands in gdal in python?

i'm read tiff data using under code. 我正在使用代码读取tiff数据。

ds = 'path' , gdal.GA_ReadOnly)

and i find gdal API, i cna't find to read number of bands. 我找到了gdal API,我找不到读取乐队的数量。

(ex) i have a 3 bands image, then read number of bands and return 3 in case) (ex)我有一个3波段图像,然后读取波段数,并返回3)

is a any way to find number of bands? 找到一些乐队的方法是什么?

The RasterCount attribute gives the band count. RasterCount属性给出了波段数。 Here's a simple example: 这是一个简单的例子:

src_ds = gdal.Open("INPUT.tif")
if src_ds is not None: 
    print ("band count: " + str(src_ds.RasterCount))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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