1

I'm using ArcMap 10.1. I want to select all vertices that contain z values and decrease their value with -0,155 meter but I dont want to change vertices that have the value=0. With this script I managed to change all vertices but how can I change it to only update those with a value?

fc = r'C:\Users\tomlin01\Documents\ArcGIS\Default.gdb\Export_Output_8'    #layer to update
z_increase = -0,155         #change in meters
with arcpy.da.UpdateCursor(fc, 'SHAPE@Z', explode_to_points=True) as cursor:    
    for row in cursor:
        cursor.updateRow([row[0] + z_increase])
  • i think first you need to select them and run your script only on selected vertices. Check this topic: link[link] – Losbaltica Feb 1 '17 at 9:44
1

Add an if statement:

fc = r'C:\Users\tomlin01\Documents\ArcGIS\Default.gdb\Export_Output_8'    #layer to update
z_increase = -0,155         #change in meters
with arcpy.da.UpdateCursor(fc, 'SHAPE@Z', explode_to_points=True) as cursor:    
    for row in cursor:
        if (row[0]<>0 and row[0] is not None):
            cursor.updateRow([row[0] + z_increase])
  • Please accept my answer with the checkmark symbol – BERA Mar 16 '17 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.