Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
    
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
up vote 10 down vote accepted

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))
share|improve this answer
    
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")
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.