[GIS] Problems using r.reclass in QGIS: invalid reclass rule error

errorgrassqgisraster

I need to reclass some rasters, but i am having a couple of problems, i can´t generate a new raster with the reclassification using the r.reclass of GRASS.
For the question here i´m using as example (images attached below) a slope raster that i need to reclass for exact values (declives_rules). When i run the operation, happens a error!

enter image description here
enter image description here

enter image description here

I wonder if i could use the raster calculator to reclass this raster?

enter image description here

enter image description here

Best Answer

The problem might be with your rule file. When you use GRASS through QGIS, it will do something similar:

  • Gather input parameters from you with a dialog box.
  • Initialize a command line GRASS instance.
  • Import the input file in a temporary GRASS location.
  • Execute a script with your parameters.
  • Export the result.
  • Draw the result on canvas (if specified).

In your custom rule file there is a little script, which will initialize r.reclass with other parameters than QGIS has collected from you. It will search for declives_map, however either it hasn't been created yet, or it has been created, but with other name. Leave the parametrizing to QGIS when you invoke GRASS from it. The correct rule file in your case is the following:

0 thru 2 = 10
2.001 thru 6 = 9
6.001 thru 12 = 5
12.001 thru 18 = 3
* = 1

enter image description here

It will create the reclassified map without a single problem.