# To select the range of values using Raster calculator in QGIS

I am working on a project where, I need to give ratings for the range of values. I have the following ratings

``````index     ratings
0 to 4       4
5 to 8       3
9 to 11      2
12 to 15     1
``````

I am using the syntax as,

``````(0<= "slope_1@1" <= 4) = 4
``````

The software identifying the syntax as valid but the result showing in null...

• The syntax is pretty different. Please, see my answer. Jun 6, 2015 at 7:00
• I edited my answer. Jun 6, 2015 at 8:18
• The process of mapping specific values or ranges of values to other values is known as reclassification or recoding. Via processing toolbox you can try the grass commands reclass and recode. Instead of giving a complex algebraic condition you simply edit a rather simple mapping file. Unfortunately most grass commands do not run in my current QGIS installation. If you would be able to run one of these commands you could solve your problem in a more general way. Jun 6, 2015 at 12:35

In your case, the complete syntax for raster calculator is:

``````(("slope_1@1" >= 0) AND ("slope_1@1" <= 4))*4 + (("slope_1@1" >= 5) AND ("slope_1@1" <= 8))*3 + (("slope_1@1" >= 9) AND ("slope_1@1" <= 11))*2+(("slope_1@1" >= 12) AND ("slope_1@1" <= 15))*1
``````

Editing Note:

The sintax in the raster calculator: It works nicely. I tested it with a raster with values between 1 and 50 (values > 15 will have red color) and the values were corroborated with Value Tool Plugin in both raster. • sir I worked out by using your syntax but I am not getting the result. Any further help..... Jun 6, 2015 at 7:59
• I tested the syntax with my own example. I will edit my answer with it. Jun 6, 2015 at 8:03

In the Processing toolbox, search for r.reclass. Double click on the GRASS tool and look at the Help tab. There are good, self-explanatory examples given.

• Thank you for your information... I'll go through with it... Jun 11, 2015 at 13:16