I have released a new beta of the Semi-Automatic Classification Plugin v.4.0 in the official repository of QGIS (experimental).
I have added a new function that was not present in the previous beta versions: a tab Band calc for calculation of raster bands using the functions provided by NumPy.
With this new tool it is possible to perform operations between raster bands such as: sum, product, sine, logarithm, etc. (for a list of NumPy function see here); also, the advanced array functions available in NumPy can be used in Band calc for calculating vegetation indices and creating complex expressions (with the prefix np.); for instance the expression np.where("raster1" > 1, 1, 0)creates a new raster having value 1 where the input raster (i.e. "raster1") is greater than 1 and 0 where input is not greater than 1, which is useful for creating masks (for more information about NumPy function "Where" see here).
The expression can use the file name of the band or the variable name (e.g. "raster1") assigned automatically. Also, the use of the variable "bandset#b" (e.g. "bandset#b1") is accepted where b is the band number of the band set defined in the tab Band set. For instance, NDVI can be easily calculated as ("bandset#b4" - "bandset#b3")/ ("bandset#b4" + "bandset#b3") . Also, it is possible to calculate multiple rasters at once by entering multiple expressions (separated by new line) such as:
"raster1" * "raster2"
"raster3" * "raster4"
that will produce one raster for "raster1" * "raster2" and another one for "raster3" * "raster4".
Read more »
The expression can use the file name of the band or the variable name (e.g. "raster1") assigned automatically. Also, the use of the variable "bandset#b" (e.g. "bandset#b1") is accepted where b is the band number of the band set defined in the tab Band set. For instance, NDVI can be easily calculated as ("bandset#b4" - "bandset#b3")/ ("bandset#b4" + "bandset#b3") . Also, it is possible to calculate multiple rasters at once by entering multiple expressions (separated by new line) such as:
"raster1" * "raster2"
"raster3" * "raster4"
that will produce one raster for "raster1" * "raster2" and another one for "raster3" * "raster4".
New tool Band calc (example of NDVI calculation)