Bug report #12573

QGIS console: 'saga:rastercalc' giving bogus values compared to other algorithms

Added by paolo prosperi almost 5 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/SAGA
Affected QGIS version:2.8.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:20701

Description

A note the issue reported under #12450, but mine seems different.
From QGIS python console, saga:rastercalculator gives bogus values compared to QGIS GUI raster calculator(same input rasters and formulas, obviously).

out = processing.runalg('saga:rastercalculator',A,[B,C],'a*b/c','false',8,None)

Just a double check, I changed algorithm:

out = processing.runalg('grass:r.mapcalculator',A,B,C,None,None,None,'A*B/C','-180,180,-90,90',0.5,None)

and got the very same results as in the QGIS GUI raster calculator.

I'm on Windows (tried both 7 and 8.1) with QGIS 2.8.1 Wien (from OSGEO4W).
I'm attaching the input rasters.

A.tif (1010 KB) paolo prosperi, 2015-04-14 01:05 AM

B.tif (86.6 KB) paolo prosperi, 2015-04-14 01:05 AM

C.tif (171 KB) paolo prosperi, 2015-04-14 01:05 AM

out_QGISGRASS.tif - Made with grass:r.mapcalculator in QGIS console (59.1 KB) paolo prosperi, 2015-04-14 06:45 AM

out_QGISGUI.tif - Made with QGIS GUI - raster calculator (1020 KB) paolo prosperi, 2015-04-14 06:45 AM

out_QGISSAGA.tif - Made with saga:rastercalculator in QGIS console (1.98 MB) paolo prosperi, 2015-04-14 06:45 AM

out_SAGAGUI.tif - Made with SAGA GUI - Grid calculus (1.98 MB) paolo prosperi, 2015-04-14 06:45 AM

History

#1 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Open to Feedback
  • Category set to Processing/SAGA

If is SAGA that makes the wrong calculations then qgis/processing cannot do anything about it. Can you test run the same operation using the SAGA command line/gui? Thanks.

#2 Updated by paolo prosperi almost 5 years ago

I am indeed having the same strange results from SAGA GUI (Grid Calculus command) as I did earlier from saga:rastercalculator in QGIS console. I don't know how to do the same with SAGA command line, sorry.
I am attaching all the results from the different algorithms used.
P

#3 Updated by Giovanni Manghi almost 5 years ago

  • Resolution set to up/downstream
  • Status changed from Feedback to Closed

paolo prosperi wrote:

I am indeed having the same strange results from SAGA GUI (Grid Calculus command) as I did earlier from saga:rastercalculator in QGIS console. I don't know how to do the same with SAGA command line, sorry.
I am attaching all the results from the different algorithms used.

SAGA gui or cli does not make difference, but if this is a SAGA issue than we cannot do anything in QGIS/Processing.

#4 Updated by paolo prosperi almost 5 years ago

Following Giovanni's response, I filed a bug in the SAGA system and, very surprisingly, this is the outcome from Olaf Conrad (http://sourceforge.net/p/saga-gis/bugs/204/):

"This is not a bug but a feature. If using grids with different grid systems, values are interpolated automatically with a spline function to meet the target grid system.
For convenience I just added an option that allows you to choose another interpolation type. Now you can choose 'nearest neighbour', if you want to reproduce the exact grass map calculator results. Alternatively resample your grids to one single grid system without interpolation (i.e. nearest neighbour) and use these with SAGA's grid calculator. Thank you for pointing at this inflexibility."

Good to know for anyone working with saga:rastercalculator tool in QGIS.

Also available in: Atom PDF