# Rounding raster values up AND down

427
2
08-11-2021 10:00 AM
Labels (2) by
New Contributor III

I'm using ArcGIS Pro 2.8.2. I have Raster Calculator code that performs well for rounding and converting my data into julian dates, but it gets the wrong final result when the decimal is above 0.5 and should be rounded up. I'd like to add a Con function to the end, but am not sure exactly how to format it. Any help would be greatly appreciated!

My current code is:

``Int((((Int(x)-1)*16)+1)+((x-Int(x))*16))``

where x represents the raster's data.

1 Solution

Accepted Solutions by MVP Esteemed Contributor

A few more functions to consider:

Round Up (used to be Ceil())

Round Down (used to be Floor())

Either of these expressions will round a value >=0.5 up and others down

``````Int(x + 0.5)
RoundDown(x + 0.5)``````

2 Replies by MVP Frequent Contributor
``````y = Int((((Int(x)-1)*16)+1)+((x-Int(x))*16))

Con( (x - Int(x) < 0.5), y, y+1)`````` by MVP Esteemed Contributor

A few more functions to consider:

Round Up (used to be Ceil())

Round Down (used to be Floor())

Either of these expressions will round a value >=0.5 up and others down

``````Int(x + 0.5)
RoundDown(x + 0.5)`````` 