Select to view content in your preferred language

Field scale (decimal places) issuse

1181
4
Jump to solution
12-31-2013 07:21 AM
TonyAlmeida
MVP Regular Contributor
I noticed that when using arcpy.CalculateField_management in python on a feature class it's changes the field scale (decimal places).
I had a shapefile with an Acres filed of field scale of 3 but now it seems to have a field scale of 11. Why after running arcpy.CalculateField_management does it change the field scale? This is annoying after your export the table and open it.

Any explanation or help would be great.

Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Tony,

I could not reproduce this with a shapefile.  However, for a File Geodatabase feature class, the Precision and Scale are ignored.  See the following link.

When you create a float, double, or integer field and specify 0 for  precision and scale, the tool will attempt to create a binary type field  if the underlying database supports it. Personal and file geodatabases  support only binary type fields, and precision and scale are ignored.

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Tony,

At first you state that you are using a feature class, then a shapefile, and then at some point you are performing an export.  Can you explain your workflow a little more?

Also, what version of the software are you using, including service packs?  i.e. 10.1 SP1

Thanks!
0 Kudos
TonyAlmeida
MVP Regular Contributor
The current script is ran in a temp gdb, i decided to run the script on a shapefile for testing because of the decimal issues i was having. After the script is ran i export the table and use the table in excel.

the calculate field looks like this.

PT = "C:\GIS\PARCEL TOOL\ParcelTool.gdb\FINAL_SF"

arcpy.CalculateField_management(PT, "Acres", "!SHAPE.AREA@Acres!", "PYTHON" )


Before running the CalculateField_management my field scale is set to 3, example Acres = 1.236
But after running CalculateField_management my field scale is set to 6, example Acres = 1.236789

I am using ArgGIS 10.1 with SP1
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Tony,

I could not reproduce this with a shapefile.  However, for a File Geodatabase feature class, the Precision and Scale are ignored.  See the following link.

When you create a float, double, or integer field and specify 0 for  precision and scale, the tool will attempt to create a binary type field  if the underlying database supports it. Personal and file geodatabases  support only binary type fields, and precision and scale are ignored.
0 Kudos
TonyAlmeida
MVP Regular Contributor
JSkinn3, oh i see. I did not catch that.

I guess i'll just have to formate cells to 3 decimal places in Excel.

Thanks.
0 Kudos