gpt4 book ai didi

python - Python ArcGIS 字段计算器中的 If/else 语句

转载 作者:太空宇宙 更新时间:2023-11-03 16:49:44 30 4
gpt4 key购买 nike

我在 arcmap 中有一个县文件,并尝试根据县名称在字段计算器中分配值。我没有编写脚本的经验。

县字段为 tl_2010_55_county10.NAMELSAD10,我尝试在其中分配值的新字段为 tl_2010_55_tract10.NitValue。类型为“短”。

我正在使用字段计算器,并且已打开 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

然后,在底部的小框中显示:!tl_2010_55_tract10.NitValue! =

我调用该函数:

myValue( !tl_2010_55_county10.NAMELSAD10!, !tl_2010_55_tract10.NitValue! )

但是,当我运行此程序时,它表示地理处理失败。

最佳答案

在大代码块中尝试一下:

Dim blah
if !tl_2010_55_county10.NAMELSAD10! = "Clark County" Then
blah=1
else blah = 0
End If

只需在 NitValue 之后的下方框中输入“blah”(不带引号)即可! =

关于python - Python ArcGIS 字段计算器中的 If/else 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35973820/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com