I have a lines feature class with the following attribute table:

enter image description here

When I run the MultipleRingBuffer_analysis function using the following code (provided by user @Emil Brundage), buffers are drawn using the sum of the "width" column of the attribute table and a list of distances 10, 20 and 30 meters.

import arcpy
arcpy.env.workspace = "C:/data/Py.gdb"
fc = "lines"
distances = [10,20,30]
sr = arcpy.Describe(fc).spatialReference
#create feature class
                                     spatial_reference = sr)
#insert cursor to insert geometries into feature class
with arcpy.da.InsertCursor ("Multibuffers", ["SHAPE@"]) as iCurs:
    with arcpy.da.SearchCursor(fc, ['SHAPE@', 'width','OID@']) as cursor:
        for geom, width, oid in cursor:
            #buffer in memory
                                             Distances=[i+width for i in distances],

            #iterate buffers and add to output feature class
            with arcpy.da.SearchCursor (r'in_memory\buffs', ["SHAPE@"]) as sCurs:
                for row in sCurs:
                    iCurs.insertRow (row)

            #delete in memory buffers
            arcpy.Delete_management (r'in_memory\buffs')

Screenshot 1

Output is one non dissolved feature class containing all the buffers as POLYGON objects (screenshot 1). I need to find a way to dissolve the buffers by ring iteration order in order to obtain something similar as screenshot 2 but with the right distances applied.

enter image description here


You cant dissolve by buffer width since each feature has different widths. Add a counting field so first buffer gets count 1, second 2, third 3 and dissolve by this:

import arcpy

infc = r'C:\database.gdb\lines'
outfc = r'C:\database.gdb\buffers'
name_of_width_field = 'width'

distances = [100,200,300]

arcpy.env.workspace = r'in_memory'
arcpy.env.overwriteOutput = 1
with arcpy.da.SearchCursor(infc, ['SHAPE@', name_of_width_field,'OID@']) as cursor:
    for geom, width, oid in cursor:
        name = r'Multibuffer_{0}'.format(oid)
                                         Distances=[i+width for i in distances], 
        arcpy.AddField_management(in_table=name, field_name='count', 
        c = 1
        with arcpy.da.UpdateCursor(name,'count') as cursor2:
            for row2 in cursor2:
arcpy.Merge_management(inputs=arcpy.ListFeatureClasses(), output='Before_dissolve')
arcpy.Dissolve_management(in_features='Before_dissolve', out_feature_class=outfc, 

enter image description here

  • Thanks BERA. Every time a buffer is drawn, the UpdateCursor give a value to the new added field, the value been dependent upon which i in distance the first loop in working one? I just began Python, trying to understand ;) – ePoQ Jan 31 '18 at 8:22
  • Yes. The order of the output of multibuffer is shortest buffer to longest buffer so it is just a matter of adding a field and calculate a Count. – BERA Jan 31 '18 at 8:25

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.