I am trying to perform a simple raster calculator that takes input rasters and outputs a new raster with a constant value where values exceed a specified number in the input.
This is part of of a QGIS script and currently works using GDAL raster calculator. However I am having issues where python stops working when running the script using GDAL RC. Therefore i'd like to adjust my script to use the SAGA GIS equivalent to perform the same process:
processing.runalg('gdalogr:rastercalculator', raster,'1',None,'1',None,'1',None,'1',None,'1',None,'1','A>0',None,5,None,OutRaster)
My question is how can I change the line above in my script to perform the same calculation using the SAGA raster calculator? That is how can I write the expression which will output a new raster with a constant value where the input raster exceeds 0.
processing.runalg("saga:rastercalculator", raster, '', 'a > 0', False, 7, OutRaster)
. You can check this post to see what the parameters are for the SAGA raster calculator: Number inputs as raster calculator variables in QGIS Modeler.processing.alghelp("grass7:r.mapcalc")
to see the parameters required. Note that the expression used would be something like"raster_name" > 0
.