3

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

6
  • 1
    Haven't used this but I think you can use r.mapcalculator (or r.mapcalc for more complex expressions) as an alternative to reclassify rasters.
    – Joseph
    Jan 12, 2015 at 15:06
  • Please provide the whole log text rather than only the last few lines which are visible in the second screenshot.
    – underdark
    Jan 12, 2015 at 15:09
  • Hi @underdark, i added a couple more screenshots, that i hope, provides more information. Jan 12, 2015 at 15:37
  • 3
    Is it possible that you try to feed a RTF file rather than a plain text file into r.reclass? The screenshot suggests that... RTF is containing control chars for layout but r.reclass needs a simple text file only.
    – markusN
    Jan 12, 2015 at 15:41
  • its correct @markusN, i change it to plain text, and amend it some mistakes in the text and worked fine. Jan 13, 2015 at 13:58

1 Answer 1

3

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.

5
  • And you need to understand the specificities of the GRASS GIS r.reclass command
    – gene
    Jan 12, 2015 at 16:01
  • If you think about the number format handling, yes, it is completely superfluous to give floating point rasters and categories as input, but it won't result in an error. The algorithm will round those numbers to the nearest integer, and in the worst case it will return a theoretically wrong classification. Jan 12, 2015 at 16:57
  • You are right @Gabor Farkas, i followed your tips and worked perfectly. Thanks a lot. Jan 13, 2015 at 12:39
  • I'm glad, it worked out, you're welcome :) Jan 13, 2015 at 14:44
  • Very nice and useful answer!
    – Joseph
    Jan 14, 2015 at 10:17

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.