python gdal警告Warning无法关闭

问题描述:读取遥感图像时gdal一直警告

Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples

具体原因可参考https://blog.csdn.net/soderayer/article/details/125438632
导致输出不美观,使用warnings.filterwarnings(‘ignore’)并不能忽略掉这些警告信息

解决方法:
在代码前加入语句

gdal.PushErrorHandler('CPLQuietErrorHandler')

你可能感兴趣的:(python,gdal)