我使用的是ArcGIS 10.2.2基本许可证,试图根据以下参数填充属性表中的一列:
'If field1 is equal to field2, return field3, if not, return 'null''
字段1和2为文本,字段3为数字。
我在字段计算器中尝试过这个代码:
预逻辑脚本代码块。。。
def calc(Score):
if ( !Field1! == !Field2!):
return !Field3!
else:
return 'null'
Score = calc(!Score!)
我对编码真的很陌生,所以我真的不确定这是否有意义(对不起),但任何帮助都将不胜感激。另外,有人知道专门为ArcGIS学习python是否是一个好的起点吗?
似乎有数百个教程,但我找不到任何专门用于编辑表格等的教程。
对于Python代码块,似乎必须使用字段作为函数参数,例如:
def score(f1, f2, f3):
if ( f1 == f2):
return f3
else:
return None
表达式:得分(!Field1!,!Field2!,!Field3!)
而对于VB脚本代码块,您可以这样做:
Dim score
if ( [Field1]== [Field2]) then
score = [Field3]
else
score = vbnull
end if
表达式:得分
请注意,只有当字段可以为null时,才能将字段值设置为null。