利用GDAL库对tif影像进行读取
示例代码默认波段为[B、G、R、NIR的顺序,且为四个波段]
import gdal
def readTif(fileName):
dataset = gdal.Open(fileName)
if dataset == None:
print(fileName+"文件无法打开")
return
im_width = dataset.RasterXSize #栅格矩阵的列数
im_height = dataset.RasterYSize #栅格矩阵的行数
im_bands = dataset.RasterCount #波段数
im_da
1