How do I manage floating point calculations in QGIS?
I have carried out 3 consecutive calculations on landsat bands. I end up with 32 bit floating point rasters on which I can't carry out a 4th calculation. The calculation result gives a substantial file but the values of the pixels are shown as "Inf".
I am not able to find a syntax guide for the float() function although I use it successfully in 1 of the preceeding calculations. And I do not have an in-depth understanding of how to manage integer/floating point or how to convert between them in QGIS.
I found these but no big clues
How to reclassify a float raster? Floating point: understanding their inaccuracy
((b5-b4)/float(b5+b4))
(float((img1-img2)/img2))
springs to mind. I have tried a lot of combinations of where the float is located, plus iterations like(float(img1-img2)/float(img2*1.0))
float
in these expressions is unlikely to cure the problem. It seems more likely that you might have a divide-by-zero issue, since all the expressions you offer are divisions and image bands typically do have zero values. Thus you should expect there to be problematic results (such asInf
) anywhere one or more of the denominators is zero (regardless of whether you use integral or floating point arithmetic). You can check this by forming the local minimum of all the bands to see whether it is everywhere zero.