AnsweredAssumed Answered

update field with change in Z value from one point to the next

Question asked by ian.irmischer on Sep 10, 2015
Latest reply on Sep 10, 2015 by ian.irmischer

I am trying to write some python code to calculate a change in Z value from one point to the next. I have a number of point files with Z values in a field called "RASTERVALU".  I have a field called zdiff that I would like to update with " Zdiff(row1)=Z(row2)-Z(row1)". I can use the update cursor it to look at the backwards change (Zdiff(row1)=z(row1)-Z(row0)) but not the forward change (Zdiff(row1)=z(row1)-Z(row0)).

 

I used the following code below but it seems like the updaterow.next() is messing up my sequential flow through the rows.  Let me know if anyone has any ideas:

 

updateRows=arcpy.da.UpdateCursor(OutputFileName,["RASTERVALU","zDiff"])

for row in updateRows:

nextRow=updateRows.next()

zdiff=nextRow[0]-row[0]

row[1]=zdiff

updateRows.updateRow(row)

 

The first run through the loop works ok but then it iterates to the third row instead of the second row. I assume it is because of my use of updateRows.next() but I am not sure. I can’t find very good documentation of the updateRow.next or any of the cursor information.

 

 

Any thoughts?

 

Ian

Outcomes