[英]If/Else Statement in Python ArcGIS Field Calculator
I need some help please!我需要一些帮助,请! I have a county file in arcmap and trying to assign values in field calculator based on county name.我在 arcmap 中有一个县文件,并尝试根据县名在字段计算器中分配值。 I don't have experience writing scripts.我没有编写脚本的经验。
The county field is tl_2010_55_county10.NAMELSAD10
, and the new field in which I am trying to assign values is tl_2010_55_tract10.NitValue
.县字段是tl_2010_55_county10.NAMELSAD10
,我尝试分配值的新字段是tl_2010_55_tract10.NitValue
。 The type is "short".类型是“短”。
I am in field calculator, and have the python "code block" up:我在现场计算器中,并打开了python“代码块”:
def myValue( !tl_2010_55_county10.NAMELSAD10!, !tl_2010_55_tract10.NitValue! ):
if ( !tl_2010_55_county10.NAMELSAD10! == "Clark County"):
!tl_2010_55_tract10.NitValue! = 1
else:
!tl_2010_55_tract10.NitValue! = 0
Then, in the little box at the bottom that says: !tl_2010_55_tract10.NitValue! =
然后,在底部的小框中显示: !tl_2010_55_tract10.NitValue! =
!tl_2010_55_tract10.NitValue! =
I call the function:我调用函数:
myValue( !tl_2010_55_county10.NAMELSAD10!, !tl_2010_55_tract10.NitValue! )
However, when I run this, it says there was a failure geo-processing.但是,当我运行它时,它说地理处理失败。 Any help would be greatly appreciated!任何帮助将不胜感激!
Thanks.谢谢。
Try this in the big codeblock:在大代码块中试试这个:
Dim blah
if !tl_2010_55_county10.NAMELSAD10! = "Clark County" Then
blah=1
else blah = 0
End If
And the just type "blah" (without the quotations) into the lower box after NitValue!只需在NitValue之后的下方框中键入“blah”(不带引号)即可! = =
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.