RasterMath Error

Issue #867 resolved
Henrike Dierkes created an issue

When trying to calculate the NDVI with the rasterMath tool and defining own output name, getting following message:

Loading resulting layers
The following layers were not correctly generated.
• C:/Users/PC/Desktop/GW/WS21_22/Week7/S2_NDVI.tif
You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.

The output is a S2_NDVI.tif.log with the follwing & a tif file “ndvi.tif”

Python command:
>>>processing.run('enmapbox:RasterMath', dict(code='# S2_26072019_HGW := QgsRasterLayer("C:/Users/PC/Desktop/GW/WS21_22/Week7/S2_26072019_HGW.bsq")\n# find bands\nred = S2_26072019_HGW@655nm\nnir = S2_26072019_HGW@865nm\n\n# calculate NDVI\nndvi = (nir - red) / (nir + red)\n\n# mask no data region\nnoDataValue = -9999\nndvi[~S2_26072019_HGWMask@655nm] = noDataValue\nndvi[~S2_26072019_HGWMask@865nm] = noDataValue\n\n# set no data value and band name\nndvi.setNoDataValue(noDataValue)\nndvi.setBandName(\'NDVI\', bandNo=1)\n\n# clean up temp variables\ndel red, nir', monolithic=False, outputRaster='C:/Users/PC/Desktop/GW/WS21_22/Week7/S2_NDVI.tif'))

Console command:
>>>qgis_process run enmapbox:RasterMath --code="# S2_26072019_HGW := QgsRasterLayer(\"C:/Users/PC/Desktop/GW/WS21_22/Week7/S2_26072019_HGW.bsq\")\n# find bands\nred = S2_26072019_HGW@655nm\nnir = S2_26072019_HGW@865nm\n\n# calculate NDVI\nndvi = (nir - red) / (nir + red)\n\n# mask no data region\nnoDataValue = -9999\nndvi[~S2_26072019_HGWMask@655nm] = noDataValue\nndvi[~S2_26072019_HGWMask@865nm] = noDataValue\n\n# set no data value and band name\nndvi.setNoDataValue(noDataValue)\nndvi.setBandName(\'NDVI\', bandNo=1)\n\n# clean up temp variables\ndel red, nir" monolithic=False outputRaster=C:/Users/PC/Desktop/GW/WS21_22/Week7/S2_NDVI.tif 

Create Raster [1338x948x1](Float64) -co INTERLEAVE=BAND COMPRESS=LZW TILED=YES BIGTIFF=YES C:/Users/PC/Desktop/GW/WS21_22/Week7\ndvi.tif
Execution completed in 0.25 seconds
Results:
{'outputRaster': None, 'ndvi': 'C:/Users/PC/Desktop/GW/WS21_22/Week7\\ndvi.tif'}

Comments (4)

  1. Andreas Janz

    Please collapse the Advanced Parameters in your screenshot,, so I can see the Output parameters.

  2. Andreas Janz

    You get the message, because you create a variable “ndvi”…

    …but the basename of the output is “S2_ndvi”

    Both names must match to avoid the message.

  3. Log in to comment