我正在尝试学习 python 并为 ArcGIS 10.1 编写 arcpy 脚本。
目标是检查各种字段的 -99 值,该值指定 NULL,然后用 0 值填充新添加的字段。代码运行......但是它用 6 值填充所有值。6 是问题的一部分,另一部分是我检查过的,表中应该只有 3 (-99) 个值。
下面是代码:
# Import arcpy module
import arcpy
print "start your engines"
# Script arguments
Shapefile = "C:\\gislab2\\Python\\take_home\\USCancer2000.shp"
#this is where the arcpy.userargument part goes, get from re-exporting model.
Field_Name = "Henry1"
Output_Feature_Class = "C:\\gislab2\\Python\\take_home\\USCancer2000.shp"
# Local variables:
USCancer2000__2_ = Output_Feature_Class
# Process: Add Field
arcpy.AddField_management(Shapefile, "Henry1", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
# Process: Calculate Field
arcpy.CalculateField_management(Output_Feature_Class, "Henry1", "5.5", "PYTHON_9.3", "")
##
### Process: If-then check for missing values
##
if "Cnt1"==-99:
Field_name=0
elif "Cnt2"==-99:
Field_name=0
elif "Cnt3"==-99:
Field_name=0
elif "Pop1"==-99:
Field_name==0
elif "Pop2"==-99:
Field_name=0
elif "Pop3"==-99:
Field_name=0