import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) gp.OverWriteOutput = 1 FC = r"C:\Program Files\ArcGIS\DeveloperKit\SamplesNET\data\Atlanta.gdb\streets" LEV2 = "JoinId" UpdateField = "CITYL" try: cur = gp.UpdateCursor(FC) row = cur.Next() while row: if row.GetValue(LEV2) == 1: row.SetValue(UpdateField, "Urban & Built-Up") cur.UpdateRow(row) row = cur.Next() except: print gp.getmessages(0) gp.addmessage(gp.getmessages(0)) del cur, row
import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) gp.OverWriteOutput = 1 FC = "C:/junk/db1.mdb/table1" # number LEV2 = "nm_area" # text UpdateField = "TEST" try: cur = gp.UpdateCursor(FC) row = cur.Next() while row: if row.GetValue(LEV2) == 1: row.SetValue(UpdateField, "Urban & Built-Up") cur.UpdateRow(row) row = cur.Next() except: print gp.getmessages(0) gp.addmessage(gp.getmessages(0)) del cur, row
import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) gp.OverWriteOutput = 1 FC = gp.GetParameterAsText(0) LEV2 = sys.argv[2] LEV1 = sys.argv[3] UpdateField = sys.argv[4] cur = gp.UpdateCursor(FC) row = cur.Next() #A = [11,12,13,14,17,18,19] #B = [15,16] #C = [21,22,23,24,25,26,27,28,29] while row: if row.GetValue(LEV2) == 11: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 12: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 13: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 14: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 17: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 18: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 19: row.SetValue(UpdateField,"Urban & Built-Up") elif row.GetValue(LEV2) == 15: row.SetValue(UpdateField,"Industrial & Mining") elif row.GetValue(LEV2) == 16: row.SetValue(UpdateField,"Industrial & Mining") elif row.GetValue(LEV1) == 2: row.SetValue(UpdateField,"Agriculture") elif row.GetValue(LEV1) == 3: row.SetValue(UpdateField,"Rangeland") elif row.GetValue(LEV1) == 4: row.SetValue(UpdateField,"Upland Forest") elif row.GetValue(LEV1) == 5: row.SetValue(UpdateField,"Water") elif row.GetValue(LEV1) == 6: row.SetValue(UpdateField,"Wetlands") elif row.GetValue(LEV1) == 7: row.SetValue(UpdateField,"Barren Land") elif row.GetValue(LEV1) == 8: row.SetValue(UpdateField,"Trans, Comm, & Util") cur.UpdateRow(row) row = cur.Next() del cur
A = [11,12,13,14,17,18,19] B = [15,16] while row: if row.GetValue(LEV2) in A: row.SetValue(UpdateField,"Urban & Built-Up") if row.GetValue(LEV2) in B: row.SetValue(UpdateField,"Industrial & Mining")
import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) gp.OverWriteOutput = 1 FC = gp.GetParameterAsText(0) LEV2 = sys.argv[2] LEV1 = sys.argv[3] UpdateField = sys.argv[4] cur = gp.UpdateCursor(FC) row = cur.Next() A = [11,12,13,14,17,18,19] B = [15,16] C = [2] D = [3] E = [4] F = [5] G = [6] H = [7] I = [8] while row: if row.GetValue(LEV2) in A: row.SetValue(UpdateField,"Urban & Built-Up") if row.GetValue(LEV2) in B: row.SetValue(UpdateField,"Industrial & Mining") if row.GetValue(LEV1) in C: row.SetValue(UpdateField,"Agriculture") if row.GetValue(LEV1) in D: row.SetValue(UpdateField,"Rangeland") if row.GetValue(LEV1) in E: row.SetValue(UpdateField,"Upland Forest") if row.GetValue(LEV1) in F: row.SetValue(UpdateField,"Water") if row.GetValue(LEV1) in G: row.SetValue(UpdateField,"Wetlands") if row.GetValue(LEV1) in H: row.SetValue(UpdateField,"Barren Land") if row.GetValue(LEV1) in I: row.SetValue(UpdateField,"Trans, Comm, & Util") cur.UpdateRow(row) row = cur.Next() del cur
## Read the dbf and populate the shp.
import arcgisscripting, sys, os
gp = arcgisscripting.create()
gp.workspace = os.getcwd()
dbf = "Apr.dbf"
shp = "Apr2009.shp"
# dbf loop
rows = gp.SearchCursor(dbf)
row = rows.Next()
while row:
# Get the value from the field(dbf)
value = row.GetValue("ID_NUM")
print "Processing ID_NUM = "+str(value)
# shp loop
rows2 = gp.UpdateCursor(shp)
row2 = rows2.Next()
while row2:
# Get the value from the field (shp)
value2 = row2.GetValue("ID_NUM")
# Populate field in shp based on a match
if value2 < 1740:
row2.city_legal = "Lower"
if value2 > 1739:
row2.city_legal = "Higher"
# Execute the new value to the shp
rows2.UpdateRow(row2)
# shp next
row2 = rows2.Next()
# dbf next
row = rows.Next()
del rows2
del rows
print "\nDone.\n"