I am having problems using the raster calculator. Some pixels of my GeoTIFF file have the value 255 on bands 1, 2 and 3. I want to replace this value with 0 on the three bands.

I tried with this formula but it does not look good:
("test@1" != 255)+("test@2" != 255)+("test@3" != 255) * "test"

enter image description here

2 Answers 2


Instead of using the raster calculator you could reclassify your raster bands. This tread lists a few options: How to reclass a raster with reclassify grid values in QGIS?

Inside QGIS you can use the GRASS module r.reclass. Reclassifying rules have to be specified in a text file or directly. I am not sure if this works directly for all bands or if you have to process each band separately.


You can't do it with raster calculator at once. Each layer needs to be converted first and then, you can stack them. Use:

("test@1" != 255)*"test@1"


If "test@1" != 255 value is 1 in result and "test@1" = 255 value is 0 in result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.