Wednesday 20 April 2016

arcgis desktop - 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?



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...