I've been having problems with the error message
Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.
This error message occurs when I open a .tiff file with wrong tiff tags, in my case the tags:
- PHOTOMETRIC_MINISBLACK = 1;
- NO(!) Extrasample
while the tiff is a RGB image with one extrasample (mask). To specify the tags before opening has no use here, since I don't know the bands in practice. I simply want to suppress the warning but haven't had success with it. I already tried the following:
- python Warnings module, suppressing all kind of warnings
- rasterio logging
This is what I do to get the Warning:
tiff = rasterio.open(path)
img = rast.read()
If you want to try it out yourself, you can find an example Tiff in the Google Drive.
Does someone know how to generally suppress the warning?
EDIT:
Here is the information about my rasterio version 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.