ArcGIS 和 Python

ArcGIS and Python

我正在努力了解 python 在 ARC 中的集成。但是我们要到下学期才能学习它,但是我认为它适合满足我对项目的需求。 (先拿了第二学期的project)

我正在尝试采用多个条件(低、中、高)并分配一个值。 5 = no 结果,4 = low,依此类推 till 0 = not present

我知道这是在使用 while 循环?

IE 
def Condition (field_16,field_8):
     While field_8 == "choice0":    
          if value(or is this field_16) == "choice0"  
               return "5"

等等,谁能给我提示或shell?

然后是condition = Condition (!field_16!)

很少卡在 arc 中 python。

谢谢!

Update Cursors 通常用于代替 ArcGIS 中的字段计算器来更新行值。游标语法通常比字段计算器界面更直观。例如:

import arcpy

fc = r'C:\path\to\your.gdb\feature_class'

with arcpy.da.UpdateCursor(fc, ["some_value_field", "some_field_to_write_values"]) as cursor:
    for row in cursor:
        """
        note that row[0] refers to "some_value_field"
        and row[1] refers to "some_field_to_write_values"
        """
        if row[0] == "low":
            row[1] = 4
        elif row[0] == "no":
            row[1] = 5
        elif row[0] == "not present":
            row[1] = 0
        cursor.updateRow(row)