Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processing] Optional band rise exception in Batch mode (QgsProcessingParameterRasterLayer) #26945

Closed
qgib opened this issue Jun 5, 2018 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Easy fix High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@qgib
Copy link
Contributor

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)
Original Redmine Issue: 19115
Affected QGIS version: 3.1(master)
Redmine category:processing/core
Assignee: Luigi Pirelli


As far I can see, most of commands that use optional QgsProcessingParameterBand fail running alg in batch mode due to control like this:
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/gdal/gdalcalc.py#L225

because the value for the band is ''.

I can fix gdalcalc, but probably it's a more general problem related with the m,eaning of default in optional QgsProcessingParameterBand

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


Hi Nyall I assign to you, just because I suppose you can fix in a minute. It's not clear to me if giving a default return to None to QgsProcessingParameterBand can have side effects


  • assigned_to_id was configured as Nyall Dawson

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


Ho to reproduce

  1. get a generic raster in qgis
  2. open processing alg: e.g. gdal raster calculator
  3. open "run as batch process"
  4. add raster layer (step1) and layer A (mandatory) and leave empty any other layer (otpionals)
  5. run =>
    Traceback (most recent call last):
    File "/mnt/data/PROGRAMMING/QGIS/QGIS-master/build/output/python/plugins/processing/algs/gdal/GdalAlgorithm.py", line 119, in processAlgorithm
    commands = self.getConsoleCommands(parameters, context, feedback, executing=True)
    File "/mnt/data/PROGRAMMING/QGIS/QGIS-master/build/output/python/plugins/processing/algs/gdal/gdalcalc.py", line 228, in getConsoleCommands
    raise QgsProcessingException(self.invalidRasterError(parameters, self.INPUT_B))
    _core.QgsProcessingException: Could not load source layer for INPUT_B: invalid value

but it is optional!


  • subject was changed from [processing] Optional band rise exception in Batch mode (QgsProcessingParameterBand) to [processing] Optional band rise exception in Batch mode (QgsProcessingParameterRasterLayer)

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


this is the run log
Processing algorithm 1/1…
Algorithm Raster calculator starting…
Input parameters:
{'BAND_A': 1,
'BAND_B': -1,
'BAND_C': -1,
'BAND_D': -1,
'BAND_E': -1,
'BAND_F': -1,
'EXTRA': '',
'FORMULA': 'A*2',
'INPUT_A': 'landcover',
'INPUT_B': '',
'INPUT_C': '',
'INPUT_D': '',
'INPUT_E': '',
'INPUT_F': '',
'NO_DATA': None,
'OPTIONS': '',
'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':/tmp/pippo.tif, 'createOptions': {}}>,
'RTYPE': 5}

Traceback (most recent call last):
File "/mnt/data/PROGRAMMING/QGIS/QGIS-master/build/output/python/plugins/processing/algs/gdal/GdalAlgorithm.py", line 119, in processAlgorithm
commands = self.getConsoleCommands(parameters, context, feedback, executing=True)
File "/mnt/data/PROGRAMMING/QGIS/QGIS-master/build/output/python/plugins/processing/algs/gdal/gdalcalc.py", line 228, in getConsoleCommands
raise QgsProcessingException(self.invalidRasterError(parameters, self.INPUT_B))
_core.QgsProcessingException: Could not load source layer for INPUT_B: invalid value

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


parameters if NOT run as batch are

Processing algorithm…
Algorithm 'Raster calculator' starting…
Input parameters:
{ 'BAND_B' : -1, 'BAND_C' : -1, 'INPUT_A' : '/home/ginetto/PROGRAMMING/GIS/GISDATA/qgis_sample_data/raster/landcover.img', 'INPUT_B' : None, 'EXTRA' : '', 'BAND_D' : -1, 'OUTPUT' : '/tmp/processing_15f1ccd70fc94dcc8af15be11fbb2182/85718598606f4759946e1883d6879506/OUTPUT.tif', 'FORMULA' : 'A*2', 'NO_DATA' : None, 'RTYPE' : 5, 'INPUT_F' : None, 'INPUT_D' : None, 'OPTIONS' : '', 'INPUT_E' : None, 'BAND_E' : -1, 'INPUT_C' : None, 'BAND_F' : -1, 'BAND_A' : 1 }

GDAL command:
gdal_calc --calc "A*2" --format GTiff --type Float32 -A /home/ginetto/PROGRAMMING/GIS/GISDATA/qgis_sample_data/raster/landcover.img --A_band 1 --outfile /tmp/processing_15f1ccd70fc94dcc8af15be11fbb2182/85718598606f4759946e1883d6879506/OUTPUT.tif

so it's clear that the way to build param disctionary works in different way depending if it is in batch or not

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


  • assigned_to_id was changed from Nyall Dawson to Luigi Pirelli

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2018

Author Name: Luigi Pirelli (@luipir)


Applied in changeset fa7879a.


  • done_ratio was changed from 0 to 100
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Jun 5, 2018
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore Easy fix labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Easy fix High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

1 participant