I would like to produce a new temporary raster after a calculation with the SAGA raster calculator using a custom python algorithm script. This is my code so far:
##MaechtigkeitunterhalbeinerHoehe=name
##Input_Raster=raster
##Hoehe=string 28.65
##Rasterout=output raster
##KoordS=crs
outputs_SAGARASTERCALCULATOR_1=processing.runalg('saga:rastercalculator', Input_Raster,[],'a - Hoehe',0,False,7,Rasterout)
It produces the error in the title. The log shows this:
Uncaught error while executing algorithm Traceback (most recent call last): File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 205, in execute self.convertUnsupportedFormats(progress) File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 296, in convertUnsupportedFormats crsid = layer.crs().authid() AttributeError: 'NoneType' object has no attribute 'crs'
2019-02-08T14:12:03 1 There were errors executing the algorithm. 2019-02-08T14:12:39 2 Error loading result layer: Traceback (most recent call last): File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\gui\Postprocessing.py", line 77, in handleAlgorithmResults isRaster) File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\tools\dataobjects.py", line 186, in load + '\nCheck the processing framework log to look for errors') RuntimeError: Could not load layer: C:\Users\saku\AppData\Local\Temp\processing2bd0c9ce76084b92b2e46ef30e6e930d\e5a1e836014f4fafb330f42ca6e8da80\Rasterout.tif Check the processing framework log to look for errors
I have checked other threads kind of regarding this topic and found out that this error usually means that SAGA produces an emtpy file, in part because of spaces in the file name or path. I checked my error log and noch such things occured.
An interesting fact is when using the SAGA Raster Calculator from the Toolbox and using the same parameters (except Hoehe
which would simply be a number) and it create a temporary tif/raster layer no problem.
How can I solve this error? Why is it working when solely using the tool from the toolbox, but not when implemented in a script?
Even when trying to save the Rasterout.tif to a different directory I get this error. This is also not what I want by the way. I need to use the temporary raster as an input for another calculation and only want to output/write and load the finished final raster layer.
I hope I described my problem clear enough.