Bug report #8619
Raster Calculator does not handle decimal values
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||17355|
Using the raster calculator rarely, i'm not an expert, but I can't believe that this intended behavior:
Trying to make a grayscale raster from an RGB, i used a formula found somewhere pointing out to be used in the QGIS raster calculator:
BandRed * 0.3 + BandGreen * 0.59 + BandBlue * 0.11
The result is a raster with all values 0.
My workaround was:
BandRed * 3/10 + BandGreen * 59/100 + BandBlue * 11/100
The resulting values,however, are float values, but i would prefer to have integer. Using int() is accepted, but has no effect.
(BTW: The is not a single word in the documentation about what other functions might be implemented)
Linux Mint 14 with QGIS 2.1 ubuntu-unstable repository
#1 Updated by arturo emiliano melchiori over 7 years ago
I am having the same behaviour with QGIS 2.0.1-Dufour and GDAL version 1.10.0. I am trying to filter a real value single band raster with a threshold of 0.15 and the result gives all values below 0. It is just not considering the decimal value.
#4 Updated by H M about 4 years ago
Still an issue in 2.18.9. Running on Linux Mint. Maybe it's about decimal separators, my locale uses ',', not '.'..? (The formula editor tells the expression is invalid if I try to use ','.)
Only the integer part is taken into account, so "xxx" + 0.5 does nothing but "xxx" + 1.5 adds 1.
Bernd's workaround works for me too.