# How to round up/down an pixel value of a raster to a pixel value with 2 decimal places?

I have a raster (DTM) with floating points as pixel value. Now i want to round up/down the pixel values (to its next nearest value) to 2 decimal places.

I use ArcGIS (with extensions) and tried the tools "int" and "round up/down" to do this but i haven't found any option to determine the number of decimal places. My next idea was to modify one of these tools within the raster calculator but unfortunatelly i don't have (enough) python skills - also with the help of google.

Do you have any easy solutions to solve this problem?

Multiply your float raster by 100, add 0.5, run Int, and divide by 100 to round to the nearest hundredth.

For example, if your floating point value was 1.629 and you want to round to two decimal places, multiply by 100, and add 0.5, which leaves you with 163.4. Run Int, which truncates the value, leaving 163. Divide by 100, leaving 1.63, the desired value.

• Related: Round raster to next higher or lower int (gis.stackexchange.com/questions/59374/…). Dec 10 '14 at 18:50
• Thank you! unfortunatelly the floating point values have different numbers of decimal places (for example, sometimes 1,4536 and sometimes 3,234). as a result, some values will be not correct anymore. Also thank you for the link! I've read it before i asked my question and it doesn't include the problem concerning the decimal places.
– Reen
Dec 11 '14 at 9:51
• It should not matter how many decimal places you have. When you run Int, there will be 3 digits left. Take 1.4536. Multiply by 100 (145.36). Add 0.5 (145.86). Run Int (145). Divide by 100 (1.45) - the correct answer. Now take 3.234. Multiply by 100 (323.4). Add 0.5 (323.9). Run Int (323). Divide by 100 (3.23) - the correct answer. Please let me know if I've got something wrong. Dec 11 '14 at 17:19
• you are right! sorry for my faulty reasoning! I've tried your suggestion (within raster calculator) - first in one line (Int(("raster" * 100) + 0.5) / 100) and step by step with the model builder once more (1.("raster" * 100) + 0.5 -> 2.Int("raster from 1.") -> 3."raster from 2." / 100). In both cases the result was wrong (58,9079 -> 58). At the step by step solution with the model builder everything works fine untill the last step (divide by 100). This is really strange to me because it doesn't seem to be that complicated.
– Reen
Dec 12 '14 at 10:22
• edit: I've found the solution! At the divide-by-100-step you have to declare your pixel values as floating points once more: 3. Float("raster from 2") / 100. OK, now I did this and according to the values/symbology of the DEM at the table-of-contents-window it seems that everything has worked out fine. But if i klick with the identify-tool into the DEM it shows: value of the original DEM -> 27,315224 and value of the new DEM -> 27,320000. Or 42,870644 (original) and 42,869999 (new) I've expected a new value like 27,32 and 42,87. Any idea?
– Reen
Dec 12 '14 at 12:42

@phloem's answer only works in cases where your raster has positive values only. For a raster `myrast` with both negative and positive values, try the following:

``````Float(Int("myrast"*100 + (("myrast" > 0)*2 - 1)*0.5))/100.0
``````