I am trying to write a "smart" way in Python to process multiple buffer to lines, polygons and points with different distances. I use Python and ArcMap 10.1. I can figure out to separate lines, polygons and points in different Feature Datasets and then to apply 3 batches with different "side type" for each Feature Dataset, but I cannot figure out how to apply different distances to each feature class contained in each Feature Dataset. I saw the post "batch buffer with python in arcgis 10 which is somehow helpful until a certain extent, but I need a further step for the different distances.

Any suggestion out there?

Best regards

  • Well, honestly, there are a LOT of possible answers to this, and it largely depends on what you're really trying to do. Are you wanting to buffer a random set of feature classes by a random distance between # miles & ## miles? Are they always going to be the same feature classes (same names) and you want each one to be buffered by a particular distance specific to that feature class? etc?? You could, for example, just add a random number generator into your script, you could use a py dictionary of FC name/distance pairs, a table of values, etc...? Also, your current code would help.
    – John
    Apr 24 '14 at 15:07
  • Based on what do you apply a different distance? Do you mean you want to make several buffers of the same feature class? Maybe then you should use Multiple Ring Buffer. As @John says your question is not very clear.
    – GISGe
    Apr 24 '14 at 15:09
  • let's make an example: 4 different polygons to which 4 different buffer distances need to be applied: - Polygon_1: 400 meters - Polygon_2: 1000 meters
    – Stefano
    Apr 24 '14 at 15:54
  • Oh sorry, let's make an example to clarify: 4 different polygons (or points or lines) to which 4 different DEFINED buffer distances ("OUTSIDE ONLY" for instance) need to be applied: - Settlements: 400 meters - Lakes: 1000 meters - Airports: 3500 meters - Protected areas: 250 meters the buffer distance is not random, but clearly defined as input data also for the other feature classes and are different from the buffer distances mentioned above for the polygons. Moreover, the number and the name of the polygons, points and lines are all different. Hopefully it helps to clarify
    – Stefano
    Apr 24 '14 at 16:06

Well, what I would do then, personally, is manually create either a python dictionary (https://docs.python.org/2/tutorial/datastructures.html#dictionaries) with the key being the FC name and value being the buffer distance, or create a table (in the GDB or separate) that has a field for FC name and a field for buffer distance. Then write your script to either loop through the dictionary or table and for each record, perform the buffer on that FC based on that buffer distance. If you have a wide variety of datasets that all need their own manually defined buffer distance, I don't think batch processing is what you need to be looking at, instead you should be looking at is iterating through a list and individually buffering each feature class based on it's buffer distance value.

That might look something like:

import arcpy
arcpy.env.workspace = "C:/data.gdb"

FCDict = {'Settlements':400,'Lakes':1000,'Airports':3500,'ProtectedAreas',250}

for fc in FCDict:
    arcpy.Buffer_analysis(fc, "C:/output/"+fc, FCDict[fc], "FULL", "ROUND", "LIST", "Distance")

That clearly is not necessarily perfect for your situation; you'd need to customize the buffer parameters and workspaces to meet your needs, if nothing else. Hopefully that gives you a starting point though. If you have questions, let me know.

  • I have to say, it is a good option. What is weird to me is the message that I get: "ExecuteError: Failed to execute. Parameters are not valid. ERROR 000728: Field Distance does not exist within table Failed to execute (Buffer)." FCDict ={'ks_parks':400,'Lakes':1000,'KS_Urban_Area':1000,'ProtectedAreas':250,'KS_Airport':5000,'natural_communities':300} for fc in FCDict: arcpy.Buffer_analysis(fc,G:\......\Scratch.gdb"+fc, FCDict[fc],"OUTSIDE_ONLY","ROUND","LIST","Distance"). Should I maybe try only with a GDB table?
    – Stefano
    Apr 24 '14 at 17:55
  • No, sorry, that's the parameters at the end of the buffer tool there. I was just copying the buffer tool code from the example at resources.arcgis.com/en/help/main/10.1/index.html#//… So you'd need to go into the last two parameters of that tool (LIST and Distance) and modify them to meet your situation's needs. Sorry, I should have made that more clear. If your data doesn't have a field called "Distance" it won't work as is... you'd have to modify those to dissolve how you want it to, if at all.
    – John
    Apr 24 '14 at 19:42
  • I'm glad it helped. If it solved your problem though, you may want to either mark my answer as accepted or post your own answer to your question explaining how you solved it and mark that answer as accepted. Either way, if you mark an answer as accepted it will remove it from the unanswered questions list, so it's easier to find questions where people still are in need of help. To accept an answer you should just have to go to the left side of a question just under the vote up/down arrows and there should be a check mark to click that'll turn green when you accept an answer.
    – John
    Apr 25 '14 at 14:13

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.