ArcGIS和Python

时间:2016-11-16 02:54:50

标签: python arcgis arcpy

我正试图了解ARC中的python集成。但是我们直到下学期才开始学习,但我认为这样才能满足我对项目的需求。 (首先是第二学期项目)

我正在尝试采用多种条件(低,中,高)并分配值。 5 = no结果,4 = lowtill 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"

等等,任何人都可以给我一个小费或外壳吗?

然后是condition = Condition (!field_16!)

几乎没有陷入弧线的蟒蛇。

谢谢!

1 个答案:

答案 0 :(得分:0)

通常使用

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)