4

I was wondering if there is a way to reduce the precision for display of a DOUBLE field of a number of fields, in a shapefile. I have 25 fields and would like to do it as automatically as possible but I'm not certain where to start. I don't particularly want to create new fields and transfer over the values manually. I am displaying the text using dynamic text on data driven pages . I just want to display it with two rather than 5-6 decimal places.

This is what the attribute table looks like, along with the relevant portion of layout:

enter image description here

Here is the field properties box: enter image description here

10
  • 1
    Are you sure these data are in a shapefile? Shapefiles don't have fields of type double: they store all numbers as ASCII strings with fixed width and fixed number of decimal places. Also, why do you make a reference to the Field Calculator? The rest of the question seems to have nothing to do with that. – whuber Aug 10 '11 at 15:50
  • I assumed that it was possible to do that with field calculator. Is that not the case? It is a shapefile. I created all of the fields myself with a python script and chose them as DOUBLE. I will append another screenshot edit: I removed the reference to field calc in the question – Emily Aug 10 '11 at 15:53
  • 1
    If you just hit the number icon in that printscreen you posted Emily, do you not have the ability to reduce the number of decimal placed right in there? – Dano Aug 10 '11 at 16:00
  • Ahh, yes, that is what I was looking for. Is there a way to do this quickly for all 25 fields? – Emily Aug 10 '11 at 16:02
  • 1
    Ok - I'm going to post this as an answer to make up for my BAD ANSWER then. Sorry I didn't read more carefully Emily – Dano Aug 10 '11 at 16:05
6

A couple of ways to accomplish these types of tasks.
1. Round ([myfield], 2) This works for field calculator, labeling, etc.
2. in the layer dialog left click the label column and select format labels
3. select the number format in the field properties and change the number of decimals.

screen1
Screen2

3

CORRECTION TO BAD ANSWER:

Just hit the circled tab in my printscreen.

enter image description here

1
  • I was trying to do this without creating new fields. – Emily Aug 10 '11 at 15:56
0

I used the arcpy.Calculatefield_managment option in ARCPY to achieve the same result

import arcpy
arcpy.env.overwriteOutput = True
Workspace = 'N:\\FGDB.gdb\\'

Feature = 'Featureclass'

In_Feature = Workspace + Feature
Field_round = 'Length_KM'
Round_operator = 'round(!Length_KM!,2)'
print Round_operator
arcpy.CalculateField_management(In_Feature, Field_round, Round_operator ,'PYTHON', '')
1
  • I recognise this is an old question but I thought a better solution was available – Leith Hawkins Mar 7 '17 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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