1

I am using ArcGIS Pro 2.7.2

I am not an experienced python programmer. My goal is that the user can select a various number of layers in the python tool and specify different buffer distances for each. I imagine it visually so that there are two columns:

Column A: Upload layer
Column B: Individual buffer distance in m

This process can be carried out until the user has specified all layers. This is important as it is currently not known how many layers are needed. Already thought about python dictionary but I do not know if this works for this case.

Finally, the buffered layers have to be loaded into a GDB.

import arcpy 
from arcpy import env 
env.workspace = "file_path"
env.overwriteOutput = True 
fcs = arcpy.ListFeatureClasses() 
bufdist = arcpy.ListFeatureClasses() 
for fc in fcs: 
    arcpy.Buffer_analysis(fc, OutputName, bufdist,"FULL", "ROUND", "LIST", "Distance") 
2
  • import arcpy from arcpy import env env.workspace = "file_path" env.overwriteOutput = True fcs = arcpy.ListFeatureClasses() bufdist = arcpy.ListFeatureClasses() for fc in fcs: arcpy.Buffer_analysis(fc, OutputName, bufdist,"FULL", "ROUND", "LIST", "Distance")
    – Felix
    Commented Apr 24, 2021 at 9:08
  • I still need a loop here, but I dont know how to manage it...
    – Felix
    Commented Apr 24, 2021 at 9:10

2 Answers 2

1

You need to explore the helpfile and read up on what is referred to as a python toolbox. This will allow you to build the tool interface that will allow your users to select multiple layers and assign buffer distances to each layer. You need to define what is called a ValueTable.

0

For those who are interested in my solution:

import arcpy
import ConversionUtils

arcpy.env.workspace = "C:/path"
arcpy.env.overwriteOutput = True
in_features = ConversionUtils.gp.GetParameterAsText(0)
in_features = ConversionUtils.SplitMultiInputs(in_features)
in_dist = arcpy.GetParameterAsText(1)
in_dist = ConversionUtils.SplitMultiInputs(in_dist)
for i in range(0, len(in_features)):
    Tmpfc = in_features[i]
    Tmpdist = in_dist[i]
    arcpy.Buffer_analysis(Tmpfc, Tmpfc+"Buffer", Tmpdist)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.