Rounding raster values up AND down

1506
2
Jump to solution
08-11-2021 10:00 AM
BeckB
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. 

0 Kudos
1 Solution

Accepted Solutions
curtvprice
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)

 

View solution in original post

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

Con( (x - Int(x) < 0.5), y, y+1)
curtvprice
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)