Jump to content

Round down raster values

Recommended Posts

Hello all,

How can i round the raster pixel values with 5 decimals to just 2 decimals in ArcGIS. I tried the round down and it converted the raster into an integer file which is not what i want. I want to make a value like 1.00469 to 1.00 or a value like 0.93589 to 0.94 etc.





Share this post

Link to post
Share on other sites

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.


@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

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

related - Round Raster to next higher or lower int

Edited by rahmansunbeam
  • Like 1

Share this post

Link to post
Share on other sites

Thank so much for the fast answer! It helped me :) In the last step where we divide by 100, we also need to define the answer has to be in float, otherwise it assumes as integer and give answer as 0 and 1:





Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

By using this site, you agree to our Terms of Use.