Buffering Multiple feature classes in GDB (python)

9641
27
05-08-2015 07:55 AM
EthanHeidtman
New Contributor III

I am having trouble buffering multiple feature classes within a GDB. These feature classes were just created based on a select by attribute and copy features tool run.

I have attached a copy of my script. The buffer analysis begins at the bottom, I have tried various parameters and dont know the variable that will be my input features that are the selected krogers from each county.

Thanks a lot!

Tags (3)
0 Kudos
27 Replies
EthanHeidtman
New Contributor III

do you think it should be something like this ^^

0 Kudos
DarrenWiens2
MVP Honored Contributor

Here's what your for-loop says:

- For each feature class:

    - make a feature layer

    - make a selection in the feature layer

    - copy the feature layer somewhere

    - buffer the feature class

EthanHeidtman
New Contributor III

here is the output from the script ran above.

its just running the buffer on the wrong fcs.

context.jpg

0 Kudos
IanMurray
Frequent Contributor

then all you need to do is make the selection FC the input, not the fc.

EthanHeidtman
New Contributor III

do you think I should run another

listFeatureclass_management with the where clause being something like (*krogerselection)

and then for fc in fcList:

     arcpy.Buffer_analysis

0 Kudos
IanMurray
Frequent Contributor

I believe you are overthinking how all this works too much.

fc isn't an object, but is holding a string value, which is the name of the feature class in your gdb.  so when the buffer tool see fc, its actually reading the string that it contains and check your workspace for a fc with that name.  You need to have it use a string of your selection FC as input, so all you need to do is have the input add the rest of the file name to it.

So you would want

arcpy.Buffer_analysis(fc + "krogerselection" , blahblah other parameters) to get the selection fc(Bro_ADDSkrogerselection for the first time through the loop)

instead of

arcpy.Buffer_analysis(fc, blahblah other parameters) that gets regular fc(Bro_ADDS for the first time through the loop)

EthanHeidtman
New Contributor III

when i run it like that, it creates a buffer for the original fcs in the GBD...

not the new kroger selection fcs.

So I think I just need to figure out what the variable is for the newly created BRO_ADDSkrogerselection (etc.) fcs.

Thanks everybody.

0 Kudos
EthanHeidtman
New Contributor III

does anyone know why my script is stopping after print "features copied and not continuing on to the next line of code..... the list feature classes line. script_stopping.JPG

0 Kudos
IanMurray
Frequent Contributor

you didn't set the list equal to a variable like you did with the first listfeatureclasses

0 Kudos
EthanHeidtman
New Contributor III

ok thank you for all the help!!!

I am going to set this fc variable to equal feature class ending in kroger selection

and then run the buffer in this for loop.

I think I have a wayyyyyyy better understanding now.

I appreciate everyone who has commented and shared advice.

This would be very simple to complete outside of python, but I guess if I had 10000 features, python would prove more useful.

Thanks again!

0 Kudos