Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Arcpy 10.0 using update cursor completes but ArcGIS crashes

$
0
0

I’m using an update cursor to iterate through my feature class, create a selection and then delete the row if it meets the condition. It partially works – I get no error messages and the script completes but then a couple of seconds later ArcGIS crashes and the resulting feature class does not have all the selected features removed. I presume I must be using the update cursor incorrectly. Here is my code:

newcur = arcpy.UpdateCursor("outlayer")
for row in newcur:
    if row.LAND1 =="Single Family ( Attached/Detached )" and row.LAND2 =="Single Family ( Attached/Detached )":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1 =="Multi Family Residential" and row.LAND2 =="Multi Family Residential":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1  =="Multi Family Residential" and row.LAND2 =="Single Family ( Attached/Detached )":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1 =="Single Family ( Attached/Detached )" and row.LAND2 =="Multi Family Residential":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1 =="Public Institutions: Schools" and row.LAND2 =="Public Institutions: Schools":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1 =="University Semi Govt" and row.LAND2 =="University Semi Govt":
        newcur.deleteRow(row)
        newcur.updateRow(row)
    if row.LAND1=="Park / Recreation / Open Space" and row.LAND2 =="Park / Recreation / Open Space":
        newcur.deleteRow(row)
        newcur.updateRow(row)
del newcur,row
gc.collect()

Viewing all articles
Browse latest Browse all 767

Trending Articles