Skip to main content
avoid subpart-part conversion
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_polarr_part.add(arr_partNone)    # Close previous sub as part
                    arr_part = arcpy.Array() # Resetsubpart
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):         # may not be necessary
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)    # Close previous sub as part
                    arr_part = arcpy.Array() # Reset
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):         # may not be necessary
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_part.add(None)    # Close previous subpart
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
comment tweaks
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)    # Close previous sub as part
                    arr_part = arcpy.Array() # Reset
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):         # may not be necessary
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)
                    arr_part = arcpy.Array()
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)    # Close previous sub as part
                    arr_part = arcpy.Array() # Reset
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):         # may not be necessary
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
loop logic
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)
                    arr_part = arcpy.Array()
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_pararr_part.count > 0):
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_par.count > 0):
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
desc = arcpy.Describe(polygon_fc)
sr = desc.spatialReference
with arcpy.da.UpdateCursor(polygon_fc, my_field) as myUpdtCur:
    for row in myUpdtCur:
        geom = row[0]
        arr_pol = arcpy.Array()
        for part in geom:            
            arr_part = arcpy.Array()
            pnt_count = 0
            for pnt in part:
                if not pnt:
                    arr_pol.add(arr_part)
                    arr_part = arcpy.Array()
                    continue     # <-- Skips hole markers
                ## assign updZpnt here
                pnt_count += 1                
                print pnt_count
                myXYZPoint = arcpy.Point(pnt.X, pnt.Y, updZpnt)
                arr_part.add(myXYZPoint)
            if (arr_part.count > 0):
                arr_pol.add(arr_part)

        row[0] = arcpy.Polygon(arr_pol,sr, True)
        myUpdtCur.updateRow(row)
doc ref; hack
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
Loading
doc ref
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
Loading
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
Loading