AnsweredAssumed Answered

Dissolve with arcpy.da.UpdateCursor

Question asked by cadd-co on Sep 13, 2015
Latest reply on Sep 23, 2015 by cadd-co

Hi, can anyone give me some guidance as to how (or if it is possible) to use arcpy.da.updatecursor to loop through multiple polylines and dissolve them one by one ? (Im on Win7, arcgis 10.2.1, Python 2.7 and the data is in an Oracle 11g sde db)


The problem I have is numerous layers that I am trying to automate removal of self overlaps but that needs to occur by objectid not by layer and I also dont want to create another dataset from the one being updated so maybe need to start an edit session first??.


While Im not a wizard at this (or I may have been able to resolve it by now), I do understand enough to be able to adjust the code below to do some other maintenance functions.


        # The "if (row[1] or 0) == 0: " code: "row[1] or 0" will return either the

        # value of the outputField, or if that value is None (null), then it will return 0...

        inputField = "SEVENTH_ID"

        outputField = "ELEVENTH_ID"

        fc = "REGION_46"

        fields = [inputField, outputField]

        with arcpy.da.UpdateCursor(fc, fields) as cursor:

            for row in cursor:

                if (row[1] or 0) == 0:

                    row[1] = row[0]


        del cursor, row    


I think what I am trying to do would look something like;

        # Dissolve the self overlaps by row for REGION_46

        # If the current row has no self overlaps, move onto the next row

        inputField = "OBJECTID"

        fc = "REGION_46"

        fields = [inputField]

        with arcpy.da.UpdateCursor(fc, fields) as cursor:

            for row in cursor:

                if (row[0] has self overlaps, use "DISSOLVE" to eliminate them

                    cursor.updateRow(row) then move onto the next row

        del cursor, row    


Anyone successfully acjieved this previously or can give me some useful guidance?

(Noting I have read the help menu and other resources numerous times and not been successful)

Cheers, Peter