【问题标题】:How to Field Calculate only the values that aren't null?如何字段仅计算不为空的值?
【发布时间】:2021-05-07 18:38:21
【问题描述】:

我正在使用 ArcPro,现场计算器。我想用消火栓检查数据填充消火栓层。 我有两个来自连接表的字段:字段 1 和字段 2。我想用字段 2 中的值填充字段 1,但前提是值不为空。基本上,如果字段 2 中的相应值为 Null,我想保留字段 1 中的值。我一直在尝试下面的 python 代码的细微变化。但它只是用所有字段 2 填充字段 1,无论是否有空值。

代码块

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass
reclass(!field1!,!field2!)

【问题讨论】:

    标签: python python-3.x gis arcgis esri


    【解决方案1】:

    我想通了!

    表达式:

    Reclass(!field1!,!field2!)
    

    代码块:

     def Reclass(f1,f2):
            if f2 is None:
                return f1
            else: 
                return f2
    

    【讨论】:

      猜你喜欢
      • 2021-08-30
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 2011-06-24
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      相关资源
      最近更新 更多