I want to run the r.reclass tool in python on a raster layer to reclassify 1 value (and leave the rest the way they are).
Here is my best attempt so far, after trying to reference documentation and other examples. Here is my code:
import processing
input_raster = QgsRasterLayer('/Users/ep9k/Desktop/Key-LogEcovaluator/Rasters/AestheticMax.tif', 'raster')
output_raster = '/Users/ep9k/Desktop/OutputReclass.tif'
rules_file = '/Users/ep9k/Desktop/reclassrules.txt'
parameters = {'Input' : input_raster,
'rules' : rules_file,
'Output' : output_raster,
'GRASS_REGION_PARAMETER' : '1277290, 1314314, -14004, 11845', #this is the exent of my raster layer
'GRASS_REGION_CELLSIZE_PARAMETER' : 0
}
processing.runAndLoadResults('grass7:r.reclass', parameters)
I run the script and I don't get any errors, but nothing happens. No output, nothing is reclassified. I think I am missing something obvious here.
Here is how I define my reclassification rules. As far as I can tell from the grass 7 documentation this is correct:
35 = 99
Really, I am reclassifying one value (35 = 99).
I get the help docs by running the following in the console:
processing.algorithmHelp("grass7:r.reclass")
Two of the input parameters are confusing to me. Specifically GRASS_RASTER_FORMAT_OPT and GRASS_RASTER_FORMAT_META. Are these required?