Skip to content
Permalink
Browse files

[processing][saga] Fix error in raster calculator

Fixes #18751
  • Loading branch information
nyalldawson committed Jun 4, 2018
1 parent a1d46de commit 268aa171cb26a1b6aed30bbaa43b2a526bbdd053
@@ -261,7 +261,8 @@ def processAlgorithm(self, parameters, context, feedback):
if isinstance(param, (QgsProcessingParameterRasterLayer, QgsProcessingParameterFeatureSource)):
command += ' -{} "{}"'.format(param.name(), self.exportedLayers[param.name()])
elif isinstance(param, QgsProcessingParameterMultipleLayers):
command += ' -{} "{}"'.format(param.name(), ';'.join(self.exportedLayers[param.name()]))
if parameters[param.name()]: # parameter may have been an empty list
command += ' -{} "{}"'.format(param.name(), ';'.join(self.exportedLayers[param.name()]))
elif isinstance(param, QgsProcessingParameterBoolean):
if self.parameterAsBool(parameters, param.name(), context):
command += ' -{} true'.format(param.name().strip())
@@ -67,3 +67,63 @@ tests:
GRID_OUT:
hash: 57437ebf7eb3667c5aa390598120967b0a2cd5d85751185bb445d1f8
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 1 input
params:
FORMULA: a*10
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params: []
type: multi
results:
RESULT:
hash: 68d805a45416467e0f1be3066dd642772cf8ffdff9535f3254cd5ffb
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 2 inputs
params:
FORMULA: a*10+b
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params:
- name: raster.tif
type: raster
type: multi
results:
RESULT:
hash: c8c2c7c32ad3eaa1ebb491aed7af7d16f1c7f574a3de1f7622894092
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 3 inputs
params:
FORMULA: a*10+b-c
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params:
- name: dem.tif
type: raster
- name: raster.tif
type: raster
type: multi
results:
RESULT:
hash: a11f159696f5726eedaa16e872fd2582cf8a88c8c1d84d72560e4647
type: rasterhash

2 comments on commit 268aa17

@ghtmtt

This comment has been minimized.

Copy link
Contributor

@ghtmtt ghtmtt replied Jun 5, 2018

@nyalldawson testing this fix. With simple operations (a*100) no problems, but with something like a>1000 I get an output as point vector (empty). Should I reopen the ticket?

Thanks!

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Jun 5, 2018

@ghtmtt check if it actually works in saga first... And if so, see if you can find what's wrong with the command qgis passes to saga

Please sign in to comment.
You can’t perform that action at this time.