Created
November 6, 2013 17:51
-
-
Save ustroetz/7340870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
# Get the feature name to work with | |
in_featureclass = arcpy.GetParameterAsText(0) | |
# Set local variables | |
field_Name = "ACRES" | |
field_Type = "DOUBLE" | |
field_Precision = 10 # total number of digits stored | |
field_Scale = 8 # number of decimal places | |
fieldList = arcpy.ListFields(in_featureclass, field_Name) | |
fieldCount = len(fieldList) | |
if fieldCount == 1: | |
# field already exists | |
arcpy.CalculateField_management(in_featureclass, field_Name, '!SHAPE.area@ACRES!', "PYTHON_9.3") | |
else: | |
#field doesn't exist | |
arcpy.AddField_management(in_featureclass, field_Name, field_Type, field_Precision, field_Scale) | |
arcpy.CalculateField_management(in_featureclass, field_Name, '!SHAPE.area@ACRES!', "PYTHON_9.3") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment