0

I'm trying to open a 12-band tiff (it stores 1 temperature image for each month of the year) using this code:

>>> from PIL import Image

>>> im = Image.open('a_image.tif')

I'm basing my procedure on this post: Working with TIFFs (import, export) in Python using numpy

However, i get the error: IOError: cannot identify image file. I've checked my path and file names. What might be causing the problem? Is it a Windows OS issue or a multiband tiff issue?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
twhawk
  • 5
  • 3
  • Can you share your TIFF please? It's rather hard to guess what the problem could be without seeing the image. – Mark Setchell Apr 23 '19 at 16:23
  • @Mark Setchell Thanks! https://www.dropbox.com/s/jf4e58o81ugv0kq/tmax_12km.tif?dl=0 – twhawk Apr 23 '19 at 16:58
  • PIL is not a good choice for handling GeoTIFF files. Try [GDAL](https://www.gdal.org/) or [rasterio](https://rasterio.readthedocs.io/en/stable/) instead. [Tifffile](https://pypi.org/project/tifffile/) can also read such TIFF files (LZW compressed floating point grayscale images with many extrasamples). – cgohlke Apr 23 '19 at 17:13
  • @cgohlke Thanks! I was successful with GDAL opening and converting tiffs to numpy. – twhawk Apr 23 '19 at 17:47

0 Answers0