BandMaths set range (min/max)



i want to set a range for a Raster file with the logical operators (<=,>=,=,if,and,then).
for example:

if geotiff >= 1 and geotiff<=2 than geotiff = 9999

Is this possible with snappy? I keep getting an error! Does anyone has an idea for an alternative (gdal,numpy,pyqgis) maybe with a code example. I cant find anything in the web since hours.

Thanks for any help!!!


The following expression worked for me.

if CHL_OC4ME >= 1.0 and  CHL_OC4ME <= 10.0 then 1 else CHL_OC4ME

Values between 1 and 10 where set to 1 other values remain unchanged.

Maybe it did not work for you because you tried to change the source value ‘geotiff’. This is not possible with Band Maths. You can’t change the input.