# Round Raster to next higher or lower int

I am using ArcGIS 10.1.

I am searching for a solution to calculate a raster. The values are like: 0.2 0.6 5.3 i.e. How can I now get 0.2 as 0 and 0.6 to 1 and 5.3 to 5? In the end integer numbers. The "roundup" and "rounddown" functions are worse to do this.

Thanks for any hints.

Luigi

-
I know this might be late but does `int(yourraster + 0.5)` really give the result? I think what it does is that it simply strips the decimal place (rounding down always). So if you use `int(5.9)` it will simply return `5` as the result. But shouldn't a round function yield `6` as result? In Python, the function `int(round(5.9,0))` will yield `5` as a result, but not sure how this is achieved within the raster calculator of ArcGIS. – Chi Michael Dec 26 '14 at 0:17
No, `Int(raster + 0.5)` will round up or down to the nearest integer, not truncate down. i.e `int(5.9 + 0.5)` is equivalent to `int(6.4)` which equals `6`. In python, try: `print int(5.9 + 0.5)`. Python will print `6`. Your comment that "in Python... `int(round(5.9,0))` will yield `5`" is also incorrect, it will return `6`. – Luke Mar 23 '15 at 20:31
I wonder how to round the raster cell values in Python? – HuH Jun 17 at 13:09
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – jbchurchill Jun 17 at 13:33

`Int(yourraster + 0.5)` will round to the nearest integer.

For rasters that may contain negative values:

``````Con(yourraster < 0, Int(yourraster - 0.5), Int(yourraster + 0.5))
``````
-
Thanks. That is want I looked for. – luigi Apr 29 '13 at 15:00
This only works if your raster contains positive values only. – mikeck Jun 15 at 15:55

If you have multiple values to reclassify from a single raster then I suggest to use "arcpy.sa.Reclassify" tool. For example:

``````outras = arcpy.sa.Reclassify(inras,"Value",RemapValue([0.2,0],[0.6,1],[5.3,5]),"DATA")
``````
-
Although this method is very flexible, it is much harder, more error-prone, and more time-consuming than Luke's answer. – whuber Apr 29 '13 at 14:44
Not my solution. ;-) – luigi Apr 29 '13 at 15:01