1

I am trying to process some raster imagery using QGIS 2.18.7 on OS X 10.10.5. I want to use a comparison operator (<, >, etc...) within the raster calculator in the process modeler (the one located under GDAL[Miscellaneous], not the SAGA one).

I can successfully get the calculator to perform an arithmetic operator by entering "A+1" in the "Calculation in gdalnumeric syntax using +-/* or any numpy array functions (i.e. logical_and())" field (quotes mine). Like I said, this works but produces an error/warning I don't understand.

Algorithm Recoding1Month starting... Prepare algorithm: GDALOGRRASTERCALCULATOR_1 Running Raster calculator 1 [1/1] Parameters: INPUT_A =/QGISWork/MODFireBurned/Tiffs/2001/y2001NicaBurnedUTM.tif, BAND_A =1, INPUT_B =None, BAND_B =1, INPUT_C =None, BAND_C =1, INPUT_D =None, BAND_D =1, INPUT_E =None, BAND_E =1, INPUT_F =None, BAND_F =1, FORMULA =(A+1), NO_DATA =, RTYPE =1, EXTRA = GDAL command: gdal_calc.py --calc "(A+1)" --format GTiff --type Int16 -A /QGISWork/MODFireBurned/Tiffs/2001/y2001NicaBurnedUTM.tif --A_band 1 --outfile /var/folders/8y/6924gdvx3jg6k2rz5yrzwz100000gr/T/processing1524180f5e1443d3a74b4fdc0a8bd484/27a58e4ed8ce4200bb71345c1a315e52/OUTPUTALGGDALOGRRASTERCALCULATOR1.tif GDAL command output: /Library/Frameworks/GDAL.framework/Versions/2.1/Programs/gdal_calc.py:272: FutureWarning: comparison to None will result in an elementwise object comparison in the future. myNDVs=1*numpy.logical_or(myNDVs==1, myval==myNDV[i]) 0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done Converting outputs OK. Execution took 0.352 ms (1 outputs). Model processed ok. Executed 1 algorithms total Converting outputs Loading resulting layers Algorithm Recoding1Month finished

More importantly, I cannot seem to get a comparison operator to produce the expected boolean (1 or 0) output when I enter "(A < 1)". In fact this crashes and fails to produce any output file. This yields the following log message:

Algorithm Recoding1Month starting... Prepare algorithm: GDALOGRRASTERCALCULATOR_1 Running [1/1] Parameters: INPUT_A =/QGISWork/MODFireBurned/Tiffs/2001/y2001NicaBurnedUTM.tif, BAND_A =1, INPUT_B =None, BAND_B =1, INPUT_C =None, BAND_C =1, INPUT_D =None, BAND_D =1, INPUT_E =None, BAND_E =1, INPUT_F =None, BAND_F =1, FORMULA =(A=, RTYPE =1, EXTRA = GDAL command: gdal_calc.py --calc "(A GDAL command output: /Library/Frameworks/GDAL.framework/Versions/2.1/Programs/gdal_calc.py:272: FutureWarning: comparison to None will result in an elementwise object comparison in the future. myNDVs=1*numpy.logical_or(myNDVs==1, myval==myNDV[i]) 0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done Converting outputs OK. Execution took 0.381 ms (1 outputs). Model processed ok. Executed 1 algorithms total Converting outputs Loading resulting layers Algorithm Recoding1Month finished

Note that, within these output logs, the command seems to be interpreted the way I'd expect for the arithmetic operator "EXTRA = GDAL command: gdal_calc.py --calc "(A+1)"" but is messed up for the comparison operator: "EXTRA = GDAL command: gdal_calc.py --calc "(A " (my external quotes). So clearly I'm making some sort of error but I cannot find helpful examples of how to format for "gdalnumeric syntax" (a Google search for this yields only 115 results) or for "numpy array functions" within the raster calculator. I found this more complex example which seems to suggest the comparison operators are possible: gdal_calc raster calculator syntax for logical operators and other functions. In fact, this (http://www.gdal.org/gdal_calc.html) seems to suggest that (A<1) should be allowed within the numpy syntax. I have tried adding quotes, but it still doesn't work. So, I'm very confused.

How can I use comparison operators with the process modeler raster calculator?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.