2

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

Marcelo Villa
  • 5,928
  • 2
  • 19
  • 38
Joc
  • 21
  • 1

2 Answers2

1

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.

MarcM
  • 1,156
  • 4
  • 19
  • Ok thanks. Do you now the syntax for my problem ? I have try the same syntax : https://gis.stackexchange.com/questions/77626/how-to-reclassify-a-raster-tiff-with-multiple-bands. But it's not working – Joc May 23 '19 at 15:53
  • Check for more information: https://grass.osgeo.org/grass70/manuals/r.reclass.html

    You could try to apply this to each band separately maybe? 255 = 0

    It is hard to test without sample data.

    – MarcM May 24 '19 at 07:55
1

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"

Cause:

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

aldo_tapia
  • 13,560
  • 5
  • 30
  • 56