Bug report #22131
SAGA raster calculator loads more grids than selected when a sdat is supplied in XGRIDS
| Status: | Closed | ||
|---|---|---|---|
| Priority: | High | ||
| Assignee: | - | ||
| Category: | Processing/SAGA | ||
| Affected QGIS version: | 3.4.8 | Regression?: | Yes |
| Operating System: | Windows 10 | Easy fix?: | No |
| Pull Request or Patch supplied: | No | Resolution: | |
| Crashes QGIS or corrupts data: | No | Copied to github as #: | 29942 |
Description
SAGA raster calculator loads more grids than selected, when a raster is supplied in .sdat format in XGRIDS.
The formula is
{ 'FORMULA' : 'a+b+c', 'GRIDS' : 'D:/Testes/saga/Z_top_res.tif', 'RESAMPLING' : 0, 'RESULT' : 'C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat', 'TYPE' : 7, 'USE_NODATA' : False, 'XGRIDS' : ['D:/Testes/saga/c.sdat','D:/Testes/saga/t_top_res.tif'] }
So, 1 raster as GRIDS (D:/Testes/saga/Z_top_res.tif), and 2 rasters as XGRIDS (D:/Testes/saga/c.sdat and D:/Testes/saga/t_top_res.tif).
However, it seems that Processing is importing the sdat raster to the SAGA format:
io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd" -FILES "D:\Testes\saga\c.sdat"
but as it is already in SAGA format, Processing uses both in raster calculator:
grid_calculus "Grid Calculator" -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd" -XGRIDS "D:\Testes\saga\c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd" -FORMULA "a+b+c" -RESAMPLING 0 -USE_NODATA false -TYPE 7 -RESULT "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat"
And obviously, the result is wrong, as the identifiers in the formula (b, c, ...) becomes a mess.
This happens in QGIS 3.4.8, 3.6.3, 3.7 (master), but not in QGIS 3.18.28. So this seems a regression.
QGIS 3.4.8
Processing algorithm…
Algorithm 'Raster calculator' starting…
Input parameters:
{ 'FORMULA' : 'a+b+c', 'GRIDS' : 'D:/Testes/saga/Z_top_res.tif', 'RESAMPLING' : 0, 'RESULT' : 'C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat', 'TYPE' : 7, 'USE_NODATA' : False, 'XGRIDS' : ['D:/Testes/saga/c.sdat','D:/Testes/saga/t_top_res.tif'] }
io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd" -FILES "D:\Testes\saga\Z_top_res.tif"
io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd" -FILES "D:\Testes\saga\c.sdat"
io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd" -FILES "D:\Testes\saga\t_top_res.tif"
grid_calculus "Grid Calculator" -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd" -XGRIDS "D:\Testes\saga\c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd" -FORMULA "a+b+c" -RESAMPLING 0 -USE_NODATA false -TYPE 7 -RESULT "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat"
C:\OSGeo4W64\bin>set SAGA=C:/OSGEO4~1/apps\saga-ltr
C:\OSGeo4W64\bin>set SAGA_MLB=C:/OSGEO4~1/apps\saga-ltr\modules
C:\OSGeo4W64\bin>PATH=C:\OSGEO4~1\apps\qgis-ltr-dev\bin;C:\OSGEO4~1\apps\grass\grass76\lib;C:\OSGEO4~1\apps\grass\grass76\bin;C:\OSGEO4~1\apps\Python37;C:\OSGEO4~1\apps\Python37\Scripts;C:\OSGEO4~1\apps\qt5\bin;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem;C:\OSGEO4~1\apps\msys\bin;C:\Program Files\RStudio\bin;C:\OSGEO4~1\apps\Python37\lib\site-packages\numpy\.libs;C:\OSGEO4~1\apps\Python37\lib\site-packages\scipy\extra-dll;C:/OSGEO4~1/apps\saga-ltr;C:/OSGEO4~1/apps\saga-ltr\modules
C:\OSGeo4W64\bin>call saga_cmd io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd" -FILES "D:\Testes\saga\Z_top_res.tif"
____________________________
##### ## ##### ##
### ### ## ###
### # ## ## #### # ##
### ##### ## # #####
##### # ## ##### # ##
____________________________
SAGA Version: 2.3.2 (64 bit)
____________________________
library path: C:\OSGEO4~1\apps\saga-ltr\modules\
library name: io_gdal
library : GDAL/OGR
tool : Import Raster
author : O.Conrad (c) 2007 (A.Ringeler)
processors : 8 [8]
____________________________
Parameters
Grids: No objects
Files: "D:\Testes\saga\Z_top_res.tif"
Select from Multiple Bands:
Alphanumeric Sorting: yes
Transformation: yes
Resampling: B-Spline Interpolation
loading: D:\Testes\saga\Z_top_res.tif
Driver: GTiff
Bands: 1
Rows: 15
Columns: 15
loading: Z_top_res
C:\OSGeo4W64\bin>call saga_cmd io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd" -FILES "D:\Testes\saga\c.sdat"
____________________________
##### ## ##### ##
### ### ## ###
### # ## ## #### # ##
### ##### ## # #####
##### # ## ##### # ##
____________________________
SAGA Version: 2.3.2 (64 bit)
____________________________
library path: C:\OSGEO4~1\apps\saga-ltr\modules\
library name: io_gdal
library : GDAL/OGR
tool : Import Raster
author : O.Conrad (c) 2007 (A.Ringeler)
processors : 8 [8]
____________________________
Parameters
Grids: No objects
Files: "D:\Testes\saga\c.sdat"
Select from Multiple Bands:
Alphanumeric Sorting: yes
Transformation: yes
Resampling: B-Spline Interpolation
loading: D:\Testes\saga\c.sdat
Driver: SAGA
Bands: 1
Rows: 15
Columns: 15
loading: c
C:\OSGeo4W64\bin>call saga_cmd io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd" -FILES "D:\Testes\saga\t_top_res.tif"
____________________________
##### ## ##### ##
### ### ## ###
### # ## ## #### # ##
### ##### ## # #####
##### # ## ##### # ##
____________________________
SAGA Version: 2.3.2 (64 bit)
____________________________
library path: C:\OSGEO4~1\apps\saga-ltr\modules\
library name: io_gdal
library : GDAL/OGR
tool : Import Raster
author : O.Conrad (c) 2007 (A.Ringeler)
processors : 8 [8]
____________________________
Parameters
Grids: No objects
Files: "D:\Testes\saga\t_top_res.tif"
Select from Multiple Bands:
Alphanumeric Sorting: yes
Transformation: yes
Resampling: B-Spline Interpolation
loading: D:\Testes\saga\t_top_res.tif
Driver: GTiff
Bands: 1
Rows: 15
Columns: 15
loading: t_top_res
C:\OSGeo4W64\bin>call saga_cmd grid_calculus "Grid Calculator" -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd" -XGRIDS "D:\Testes\saga\c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd" -FORMULA "a+b+c" -RESAMPLING 0 -USE_NODATA false -TYPE 7 -RESULT "C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat"
____________________________
##### ## ##### ##
### ### ## ###
### # ## ## #### # ##
### ##### ## # #####
##### # ## ##### # ##
____________________________
SAGA Version: 2.3.2 (64 bit)
____________________________
library path: C:\OSGEO4~1\apps\saga-ltr\modules\
library name: grid_calculus
library : Calculus
tool : Grid Calculator
author : A.Ringeler (c) 2003
processors : 8 [8]
____________________________
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/240dff11e1314783baa2a5dab944de47/Ztopres.sgrd...
Load grid: D:\Testes\saga\c.sgrd...
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/b876b2b72535404b883a06d0fdedb4a0/c.sgrd...
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/9a1d1134e6ca4ad68ee59e5424d627b8/ttopres.sgrd...
Parameters
Grid system: 1000; 15x 15y; 472000x 4740000y
Grids: 1 object (Ztopres)
Grids from different Systems: 3 objects (c, c, ttopres)
Resampling: Nearest Neighbour
Result: Result
Formula: a+b+c
Name: Calculation
Take Formula: no
Use NoData: no
Data Type: 4 byte floating point number
Warning: The number of supplied grids exceeds the number of variables in formula. (4 > 3)
C:\OSGeo4W64\bin>exit
Execution completed in 20.79 seconds
Results:
{'RESULT': 'C:/Users/pedro.venancio/AppData/Local/Temp/processing_87ca241799e54598a3ff48cbb44bb515/bbebbd5d3a774a8890c3295a40ce2bde/RESULT.sdat'}
Loading resulting layers
Algorithm 'Raster calculator' finished
QGIS 3.6.3
QGIS version: 3.6.3-Noosa
QGIS code revision: 0c5774c068
Qt version: 5.11.2
GDAL version: 2.4.1
GEOS version: 3.7.2-CAPI-1.11.0 b55d2125
PROJ version: 520
Processing algorithm…
Algorithm 'Raster calculator' starting…
Input parameters:
{ 'FORMULA' : '((c-b)/a)*1000', 'GRIDS' : 'D:/Testes/saga/Z_top_res.tif', 'RESAMPLING' : 0, 'RESULT' : 'D:/Testes/saga/d.sdat', 'TYPE' : 7, 'USE_NODATA' : False, 'XGRIDS' : ['D:/Testes/saga/c.sdat','D:/Testes/saga/t_top_res.tif'] }
grid_calculus "Grid Calculator" -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/00c571a7d64f4b32b11eca2358b66db2/Ztopres.sgrd" -XGRIDS "D:\Testes\saga\c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/4c2d1f3a6ac74f2fa23aa3366da7f0a5/c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/dceb5630dc704f7cab4c29ccdd82266b/ttopres.sgrd" -FORMULA "((c-b)/a)*1000" -RESAMPLING 0 -USE_NODATA false -TYPE 7 -RESULT "D:/Testes/saga/d.sdat"
C:\WINDOWS\system32>set SAGA=C:/OSGEO4~1/apps\saga-ltr
C:\WINDOWS\system32>set SAGA_MLB=C:/OSGEO4~1/apps\saga-ltr\modules
C:\WINDOWS\system32>PATH=C:\OSGEO4~1\apps\qgis-rel-dev\bin;C:\OSGEO4~1\apps\grass\grass76\lib;C:\OSGEO4~1\apps\grass\grass76\bin;C:\OSGEO4~1\apps\Python37;C:\OSGEO4~1\apps\Python37\Scripts;C:\OSGEO4~1\apps\qt5\bin;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem;C:\OSGEO4~1\apps\msys\bin;C:\Program Files\RStudio\bin;C:\OSGEO4~1\apps\Python37\lib\site-packages\numpy\.libs;C:\OSGEO4~1\apps\Python37\lib\site-packages\scipy\extra-dll;C:/OSGEO4~1/apps\saga-ltr;C:/OSGEO4~1/apps\saga-ltr\modules
C:\WINDOWS\system32>call saga_cmd grid_calculus "Grid Calculator" -GRIDS "C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/00c571a7d64f4b32b11eca2358b66db2/Ztopres.sgrd" -XGRIDS "D:\Testes\saga\c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/4c2d1f3a6ac74f2fa23aa3366da7f0a5/c.sgrd;C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/dceb5630dc704f7cab4c29ccdd82266b/ttopres.sgrd" -FORMULA "((c-b)/a)*1000" -RESAMPLING 0 -USE_NODATA false -TYPE 7 -RESULT "D:/Testes/saga/d.sdat"
____________________________
##### ## ##### ##
### ### ## ###
### # ## ## #### # ##
### ##### ## # #####
##### # ## ##### # ##
____________________________
SAGA Version: 2.3.2 (64 bit)
____________________________
library path: C:\OSGEO4~1\apps\saga-ltr\modules\
library name: grid_calculus
library : Calculus
tool : Grid Calculator
author : A.Ringeler (c) 2003
processors : 8 [8]
____________________________
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/00c571a7d64f4b32b11eca2358b66db2/Ztopres.sgrd...
Load grid: D:\Testes\saga\c.sgrd...
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/4c2d1f3a6ac74f2fa23aa3366da7f0a5/c.sgrd...
Load grid: C:/Users/pedro.venancio/AppData/Local/Temp/processing_6202d43c755f430da81bf61495949469/dceb5630dc704f7cab4c29ccdd82266b/ttopres.sgrd...
Parameters
Grid system: 1000; 15x 15y; 472000x 4740000y
Grids: 1 object (Ztopres)
Grids from different Systems: 3 objects (c, c, ttopres)
Resampling: Nearest Neighbour
Result: Result
Formula: ((c-b)/a)*1000
Name: Calculation
Take Formula: no
Use NoData: no
Data Type: 4 byte floating point number
Warning: The number of supplied grids exceeds the number of variables in formula. (4 > 3)
C:\WINDOWS\system32>exit
Execution completed in 5.87 seconds
Results:
{'RESULT': 'D:/Testes/saga/d.sdat'}
Loading resulting layers
Algorithm 'Raster calculator' finished
Associated revisions
[processing] do not export sdat files provided as part of a multiple raster input
fixes #22131
[processing] do not export sdat files provided as part of a multiple raster input
fixes #22131
[processing] do not export sdat files provided as part of a multiple raster input
fixes #22131
History
#1
Updated by Victor Olaya over 6 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|94e13289b877df9c42c827eab5b2802beb5a18ca.