Using gdal_calc.py with conditionals on a float not giving correct results

You can get what you want simply by using the following expression:

--calc="((1.0*A/B) >= 0.5)"

There is no need to use gdal_translate to convert your source rasters as floats. Multiplying by 1.0 is casting the byte array as float, so the division is made in the float domain.


Use gdal_translate to adjust your rasters to Float first and then you can do the math and avoid the integer division. http://www.gdal.org/gdal_calc.html

Tags:

Python

Gdal