1

I have a tif image that I'm trying to run gdal_calc.py. In the source file the values are between 1,118-9,704 and I want to divide all the values by 10,000 to get results between 0-1.

This is the command I run:

gdal_calc.py --type=Float32 -A C:\z\input.tif --outfile=C:\z\output.tif --calc="A/10000"

The problem is that the output is not working, it seems that it does not know how to get decimal numbers.

I display the output in ArcMap software

Anyone have an idea?

2

The division in gdal is an integer division by default. You can change this behaviour by dividing with a float. In you case, simply replace 10000 by 10000.0

gdal_calc.py --type=Float32 -A C:\z\input.tif --outfile=C:\z\output.tif --calc="A/10000.0"

Note that storing in 16bit integer is more efficient than float 32, so I should think twice before running this type of conversion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.