I am trying to create a toolbox that will generate a buffer around 2 feature classes. ]1

I feel like I am missing out a few minor things and that there is something wrong with my toolbox parameters?

  • please add you code as text, rather than an image – MacroZED Nov 27 '17 at 13:41
  • @MacroZED done it – hazard335 Nov 27 '17 at 13:50
  • 1
    Buffer roads, buffer schools, erase road buffer with school buffer using Erase tool – BERA Nov 27 '17 at 14:00
  • @BERA I think i have an issue with the buffer aspect of my code. When I specify the buffer distances for the 2 feature classes in the tool - the result shows both feature classes having the same buffer distance – hazard335 Nov 27 '17 at 14:28
  • @BERA Yes that what it is - 1000 meters – hazard335 Nov 27 '17 at 14:35

With this:

for fc in bufferList:
     arcpy.Buffer_analysis(fc, fc + "Buffer", arcpy.GetParameterAsText(2), "", "", "ALL")
     arcpy.Buffer_analysis(fc, fc + "Buffer", arcpy.GetParameterAsText(3), "", "", "ALL")

You are buffering roads twice, first with 1000 m and then you overwrite this with a buffer of 100 m, then you are doing the same for the schools.

There is no need to use a for loop. And Erase tool is what you want:

arcpy.Buffer_analysis(arcpy.GetParameterAsText(0), arcpy.GetParameterAsText(0) + '_buffer', arcpy.GetParameterAsText(2), "", "", "ALL")
arcpy.Buffer_analysis(arcpy.GetParameterAsText(1), arcpy.GetParameterAsText(1) + '_buffer', arcpy.GetParameterAsText(3), "", "", "ALL")

arcpy.Erase_analysis(in_features=arcpy.GetParameterAsText(0) + '_buffer', erase_features=arcpy.GetParameterAsText(1) + '_buffer', out_feature_class=arcpy.GetParameterAsText(4))

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.