I'm working with jupyter and I have been trying to open TIFF images that I have download from GEE. I have trying to open the images in Jupyter environment.

This is my code:

from PIL import Image
import numpy 

img = Image.open("NDVI.tif")

but I get the following error message:

OSError Traceback (most recent call last) in ----> 1 img = Image.open("NDVI.tif")

~\Anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode) 2820
for message in accept_warnings: 2821 warnings.warn(message) -> 2822 raise IOError("cannot identify image file %r" % (filename if filename else fp)) 2823 2824

OSError: cannot identify image file 'NDVI.tif'

I have tried to change the raster nae to end with TIFF and tiff but didn't help. How can I solve this?

EDIT: This is where my jupyter notebook is and where the tif are: enter image description here

  • What are you trying to do? If you need to process the images mathematically, it's better to use rasterio, it will read it into a numpy matrix and then you'd process it. Otherwise, I'm not sure, but probably the Tiff has some special data type (intX, for instance). – culebrón Nov 14 at 14:38
  • @culebrón i'm trying to create scattter plot between two bands ,each band in different image – Reut Nov 14 at 14:40
  • then you definitely need to use rasterio. rasterio.readthedocs.io/en/stable – culebrón Nov 14 at 14:44
  • 1
    I can open whatever image with Image method from PIL. So, you don't have 'NDVI.tif' in your work directory, Anaconda cannot interpret adequately your path or your image is corrupted. – xunilk Nov 14 at 15:07
  • oh, @xunilk is right. My bad. – culebrón Nov 14 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.