AnsweredAssumed Answered

Update Cursor not updating field with value

Question asked by roy_hewitt on Feb 14, 2012
Latest reply on Feb 14, 2012 by Dan_Patterson
I'm writing a script for field staff that clips all wetlands in a watershed, calculates area (hectares) and multiples by a sampling factor to see how many hectares need to be sample

Here is a sample of the update cursor part of the code:
         rows = arcpy.UpdateCursor(newWetland) row = rows.next()  while row:      if row.getValue(wetlandTypeField) == 'Estuarine and Marine Wetland':           totalHectares = row.getValue(areaField)           sampleArea = (totalHectares * .25) # Sample 25% of this type           row.setValue(sampleField, sampleArea)           rows.updateRow(row)           row = rows.next()      elif row.getValue(wetlandTypeField) == 'Freshwater Emergent Wetland':           totalHectares = row.getValue(areaField)           sampleArea = (totalHectares * .25) # Sample 25% of this type           row.setValue(sampleField, sampleArea)           rows.updateRow(row)           row = rows.next()


There are several more elif blocks for each wetland type in the dataset.

When I type in the python window:
print sampleArea

I get the correct area, however, it does not update the row.  The help files indicate that the second parameter of the row.setValue() method is supposed to be an object.  Could that be the problem?

Any help would be appreciated.
Roy

Outcomes