ENVI匯出的tif檔案,python讀取失敗。

隕星落雲發表於2020-12-10

ENVI中直接儲存為tif或TIF的檔案,python讀取失敗。
報錯如下:

Traceback (most recent call last):
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/tifffile/tifffile.py", line 2296, in __init__
    byteorder = {b'II': '<', b'MM': '>', b'EP': '<'}[header[:2]]
KeyError: b'\x00\x00'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "beijing_landsat.py", line 19, in <module>
    band1 = imageio.imread(path+img_path[:-1]+'1.tif')
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/imageio/core/functions.py", line 265, in imread
    reader = read(uri, format, "i", **kwargs)
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/imageio/core/functions.py", line 186, in get_reader
    return format.get_reader(request)
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/imageio/core/format.py", line 170, in get_reader
    return self.Reader(self, request)
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/imageio/core/format.py", line 221, in __init__
    self._open(**self.request.kwargs.copy())
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/imageio/plugins/tifffile.py", line 226, in _open
    self._tf = _tifffile.TiffFile(f, **kwargs)
  File "/data/wdh/.conda/envs/AI_studywdh/lib/python3.6/site-packages/tifffile/tifffile.py", line 2298, in __init__
    raise TiffFileError('not a TIFF file')
tifffile.tifffile.TiffFileError: not a TIFF file

解決方法:
請使用另存為選項
file—>save as
在這裡插入圖片描述

相關文章