ArcGIS和Python

2024-05-19 08:36:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试着了解ARC中的python集成。但我们要到下学期才学会,不过我觉得它适合我的项目。(第一学期参加第二学期专题)

我正在尝试接受多个条件(低、中、高)并赋值。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"

等等,有人能给我小费吗?你知道吗

然后是condition = Condition (!field_16!)

有点被Python困住了。你知道吗

谢谢!你知道吗


Tags: 项目nofieldnotcondition条件low专题
1条回答
网友
1楼 · 发布于 2024-05-19 08:36:55

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) 

相关问题 更多 >

    热门问题