0

I'm facing an issue when opening a .tif using rasterio using the code below.

fp = 'image.tif'
image = rasterio.open(fp)
print(image.read())

When printing the content of the image, I get this

[[[0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]
  ...
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]]]

I verified all values and they are all 0. However, when dragging the image in QGIS, I can view it and confirm that the image contains values ranging from 101 to 122.

QGIS image

Any idea on how to read the image and get these 101 to 122 values as a numpy array ?

Here's a link to the image in question

Loic
  • 13
  • 3
  • Please share the TIFF - use Dropbox or Google Drive maybe. – Mark Setchell Sep 13 '22 at 17:30
  • @MarkSetchell added a shareable link at the end of the description. – Loic Sep 13 '22 at 18:17
  • Your file seems to be as you describe it, so there's either something wrong with your rasterio installation or something wrong with your analysis. For the former, try reinstalling rasterio, or using `tifffile` on PYPI to read it, or `vips`. For the later, try checking `np.mean(image)` and `image.max()`. – Mark Setchell Sep 13 '22 at 18:42
  • It works with `tifffile`, but I need functions from `rasterio`. Image seems to be of dtype 'uint8', I'll see if I can research how to open that in `rasterio`. – Loic Sep 14 '22 at 12:10

0 Answers0