Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to use the Field Calculator in ArcMap to round an existing column to two decimals. Currently I have a column that is 6 decimal places long and would like to simply round it down to 2 decimals.

I had planned on using the Field Calculator (possibly using Python) to do this, but maybe there is an easier way?

Edit

The accepted answer is probably the easiest way to change a single field, however, here is how to do it with the field calculator for both python and VB.

VB:

round([column], 2)

Python:

round(!column!, 2)
share|improve this question
2  
An appropriate Field Calculator expression can change the data so that they closely approximate multiples of 0.01. How close depends on how the field is stored; it will differ between floats, doubles, and decimal encoding. (The first two formats cannot exactly store certain values, such as 0.03 = 1.1000001111010111000010100011110...B, which is a repeating infinite binary expression.) Do you perhaps intend to change the field itself so that it accurately stores only decimal numbers with two decimal places? –  whuber Jan 3 '12 at 20:04

3 Answers 3

up vote 8 down vote accepted

When you go to dispay, calculate or label the field you could just use,
round ([my_field],2)
also to change the field behavior in arcmap...
rounding example

share|improve this answer
    
crisscrossed with your edit. oops –  Brad Nesom Jan 3 '12 at 20:42
    
It's ok, really liked the field behavior bit of knowledge. For what I am doing that would suffice. –  jsmith Jan 3 '12 at 20:49

Have you tried something like what's below in the Field Calculator?

round(!FieldName!, 2)

Make sure you set the Parser to Python in the Field Calculator.

share|improve this answer
1  
Yup, that's the python way! Apparently it's the exact same thing as the VB way (if you double click on the field to add it). The only difference is ! vs []. –  jsmith Jan 3 '12 at 21:40

Sounds like some simple string formatting would do the trick for you:

>>> "%.2f" % 3.99999
'4.00'
>>>

or, with the number stored in a variable:

>>> j = 3.999999
>>> "%.2f" % j
'4.00'
>>>

This could easily be wrapped up in a Field Calculator function.

share|improve this answer

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.