Hi,I'm trying to use python to add a field and add some text for an attribute class. Funny thing is (actually not so funny) update cursor returns an error and destroys my raster!import arcpy
#import os
from arcpy.sa import *
from arcpy import env
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
WScom4_rc = "X:\\DATA\\watershed_100mbuf_lc_8class.img"
arcpy.AddField_management(WScom4_rc, "Class_Name", "TEXT")
rows = arcpy.UpdateCursor(WScom4_rc)
for row in rows:
if row.Value == 1:
row.Class_Name = "Forest"
rows.updateRow(row)
if row.Value == 2:
row.Class_Name = "Developed"
rows.updateRow(row)
if row.Value == 3:
row.Class_Name = "Fields/Pastures"
rows.updateRow(row)
if row.Value == 4:
row.Class_Name = "Wetlands"
rows.updateRow(row)
if row.Value == 5:
row.Class_Name = "Water"
rows.updateRow(row)
if row.Value == 6:
row.Class_Name = "Barren/Soil"
rows.updateRow(row)
if row.Value == 7:
row.Class_Name = "Open Space"
rows.updateRow(row)
if row.Value == 8:
row.Class_Name = "Deforested"
rows.updateRow(row)
if row.Value == 9:
row.Class_Name = "Ice/Snow/Shadow (unclassified)"
rows.updateRow(row)
Here is the error code: Traceback (most recent call last): File "X:\DATA\FloodRisk2_Canada\02_Source_Data\2_Working_Source_Data\Goulds_working\FloodVul_process_script1_goulds.py", line 74, in <module> row.Class_Name = "Forest" File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\_base.py", line 35, in __setattr__ return setattr(self._arc_object, attr, ao)RuntimeError: ERROR 999999: Error executing function.The input raster has a normal raster attribute table: Rowid, value, count.The output is an empty raster where the attribute table contains Rowid, value, count, and Class, but no rows (no data). Can update cursor be used for editing raster attributes? If so, How?Thanks!Rich