# Rounding raster values in QGIS raster calculator?

Is it possible to round raster value in QGIS to a given number of digits? I have raster data with temperatures as values but the authors have made the values Celsius * 10. That is, a temperature of 2.5 is stored as 25. When I use the following formula in the Raster Calculator:

``````"july_merged@1" * .1
``````

...the result is 2.599999904632568. I just want the 2.5.

As an alternative, you can use in QGIS the gdal.calc module located in : Processing toolbox > GDAL/OGR > GDAL - Miscellaneous > Raster calculator • Type in the formula : round (A,2) The details of the function used comes from numpy array functions :

• round_(a[, decimals, out]) Round an array to the given number of decimals.

This way, you can master the way the values are rounded. See below the result. In a commandline way :

``````gdal_calc --calc "Round(A,2)" --format GTiff --type Float32 -A \\my\path\input.tif --A_band 1 --outfile \\my\path\output.tif
``````
• `gdal_calc --calc "Round(A,2)"` - correct syntax may depend on Numpy version. For me `round_(A,2)` works with numpy 1.11. – jurajb Mar 19 '18 at 11:29
• Hum...good point. Maybe i made a mistake in the final formula. I should check it out... From what I read in my own message (round_(a[, decimals, out]) Round an array to the given number of decimals.), i would say the right syntax is yours.. – gisnside Mar 19 '18 at 14:22

There's no built-in round function (which, ugh why), but this question provides a workaround - How to round up/down an pixel value of a raster to a pixel value with 2 decimal places?

In your case, replace multiply by 100 with multiply by 10 since you only want 1 decimal place.

• No, it still adds all of those decimal places. I tried all of the calculations on that page. – Jim Aug 14 '16 at 21:18