I have a Tiff file that has no data value = -3.40282347e+38. I want to filter no data and get raw values with gdal. I tried with below code:
import numpy as np
from osgeo import gdal, gdal_array
dataset = gdal.Open("path/to/file.tif")
array = dataset.ReadAsArray()
lst = []
for v in array:
if v < 0:
lst.append(v)
print lst
but I received this error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/tmp/tmp3B0d5H.py", line 10, in <module>
if v < 0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
How can I do it?