我一直遇到一个错误消息:警告1:TIFFReadDirectory:与SamplesPerPixel不匹配的颜色通道和ExtraSamples总和。将非颜色通道定义为ExtraSamples。当我使用错误的Tiff标签打开.tiff文件时会出现此错误消息,在我的情况下标签如下:
PHOTOMETRIC_MINISBLACK = 1; NO(!)Extrasample 而该tiff是具有一个extrasample(掩码)的RGB图像。在此之前指定标签没有用,因为在实践中我不知道波段。我只想压制警告,但一直没有成功。我已经尝试过以下方法:
Python Warnings模块,抑制所有类型的警告 rasterio日志记录
这是我获取警告的方法:
如果您想自行尝试,请在Google Drive中找到示例Tiff。
有人知道如何通常抑制警告吗?
编辑: 这是我的rasterio版本信息
PHOTOMETRIC_MINISBLACK = 1; NO(!)Extrasample 而该tiff是具有一个extrasample(掩码)的RGB图像。在此之前指定标签没有用,因为在实践中我不知道波段。我只想压制警告,但一直没有成功。我已经尝试过以下方法:
Python Warnings模块,抑制所有类型的警告 rasterio日志记录
这是我获取警告的方法:
tiff = rasterio.open(path)
img = rast.read()
如果您想自行尝试,请在Google Drive中找到示例Tiff。
有人知道如何通常抑制警告吗?
编辑: 这是我的rasterio版本信息
pip show -v rasterio
:Name: rasterio
Version: 1.2.10
Summary: Fast and direct raster I/O for use with Numpy and SciPy
Home-page: https://github.com/mapbox/rasterio
Author: Sean Gillies
Author-email: sean@mapbox.com
License: BSD
Location: /home/david/miniconda3/lib/python3.9/site-packages
Requires: click-plugins, numpy, snuggs, cligj, click, setuptools, affine, certifi, attrs
Required-by: rioxarray
Metadata-Version: 2.1
Installer: pip
Classifiers:
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Information Technology
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Programming Language :: C
Programming Language :: Cython
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3
Topic :: Multimedia :: Graphics :: Graphics Conversion
Topic :: Scientific/Engineering :: GIS
Entry-points:
[console_scripts]
rio=rasterio.rio.main:main_group
[rasterio.rio_commands]
blocks=rasterio.rio.blocks:blocks
bounds=rasterio.rio.bounds:bounds
calc=rasterio.rio.calc:calc
clip=rasterio.rio.clip:clip
convert=rasterio.rio.convert:convert
edit-info=rasterio.rio.edit_info:edit
env=rasterio.rio.env:env
gcps=rasterio.rio.gcps:gcps
info=rasterio.rio.info:info
insp=rasterio.rio.insp:insp
mask=rasterio.rio.mask:mask
merge=rasterio.rio.merge:merge
overview=rasterio.rio.overview:overview
rasterize=rasterio.rio.rasterize:rasterize
rm=rasterio.rio.rm:rm
sample=rasterio.rio.sample:sample
shapes=rasterio.rio.shapes:shapes
stack=rasterio.rio.stack:stack
transform=rasterio.rio.transform:transform
warp=rasterio.rio.warp:warp
Note: you may need to restart the kernel to use updated packages.