How can I execute from the console an expression that should be used with the raster calculator?
I'm searching for something like this:
qgis.someRasterCalcClass.evaluate("boh@1 + boh@2", "outputfile.tif")
Starting from QGIS 2.0 (and current development version), the class QgsRasterCalculator is available in python. Unfortunately it is not very well documented.
The basic usage is, that you have to define an alias for each band used in the calculator expression in form of a QgsRasterCalculatorEntry
Your example can then be written as follows, given you have already assigned your rasterlayer to a variable bohLayer.
The return of processCalculation() will be
The layer is not automatically added to the TOC, so either do this manually or with some python code.