2016-11-16 59 views
0

我試圖讓我的頭圍繞着Python的Python集成。但是我們直到下個學期才學習它,但是我認爲它適合滿足我對我的項目的需求。 (在第一學期第一個項目)ArcGIS和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!)

小卡在弧蟒。

謝謝!

回答

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)