Hi all,
I need some help with python code and buffer in ArcGIS:
A set of polygons (all in one featureclass, circular shapes) should get several buffers (e.g. 40 times). Each feature gets a different buffer distance, it is stored in corresponding field in attribute table. So the first buffer distance is taken from value in table, the following are calculated by "buffer*i", "i" is counting from 1 to 40. For example:
If first feature has the value 400 metres, first buffer for that feature would be 400 metres, 2nd 800 metres, 3rd 1200 metres,.... (measured from the origin shape).
I had two attempts, both are not working the way I like:
import arcpy
arcpy.env.workspace = r"R:\Base.gdb"
fc = "export"
fieldname = "Buffer"
i = 1
while i <= 40:
outName = fc+"_" + str(i)
dist = (fieldname)*i
arcpy.Buffer_analysis(fc, outName, dist)
i = i+1
Result: First Buffer OK, then abortion, because cannot find fieldname "BufferBuffer" (sure, multiplication of fieldname, but how to calculate with value and not with the name?).
import arcpy
arcpy.env.workspace = r"R:\Base.gdb"
fc = "export"
fieldname = "Buffer"
cursor = arcpy.SearchCursor(fc)
row = cursor.next()
i = 1
while i <= 40:
outName = fc+"_" + str(i)
dist = row.getValue(fieldname)*i
arcpy.Buffer_analysis(fc, outName, dist)
i = i+1
Result: No Abortion, but all buffers are calculated based on one value from first feature in attribute table, not the corresponding.
In case of using QGis, there are some plugins for multiple buffer, but they work just with static values.
Maybe it's just a short fix in code, who could help me?