1

I am trying to set up a custom tool via a python script in ArcMap. I want the tool to be able to create a point feature with X/Y input and then pass that point into the buffers.

My thinking is that someone could use the tool to find what is inside the radius from their given point that they input themselves without having to create a feature class first (I hope that makes it clearer).

Am I doing this right by creating the point feature and using the GetParameterAstext string? What exactly would go in the multiple ring buffer at the bottom?

import arcpy
import os

# Create a Point object from coordinates then set up buffer rings    
pnt.X = arcpy.GetParameterAsText(0)
pnt.Y = arcpy.GetParameterAsText(1)
arcpy.Point(pnt.X, pnt.Y) = arcpy.GetParameterAsText(2)

BuffRing1 = arcpy.GetParameterAsText(3)
BuffRing2 = arcpy.GetParameterAsText(4)

distances = [BuffRing1, BuffRing2]
measure = ['miles']

arcpy.MultipleRingBuffer_analysis()
3
  • To understand what parameters go into any ArcPy command, the best resource is the Esri help pages (in this case, for Multiple Ring Buffer). Parameters in curly brackets {} are optional. Any of these input parameters can either be hard-coded by you (for example, you might always want Buffer_Unit to be "Miles"), or passed in as variables that are set from user input parameters.

    arcpy.MultipleRingBuffer_analysis(
        Input_Features,
        Output_Feature_class,
        Distances,
        {Buffer_Unit},
        {Field_Name},
        {Dissolve_Option},
        {Outside_Polygons_Only})
    
  • You'll need to specify the Output_Feature_class since it is a required parameter of the tool. That can be either user-controlled, or hard-coded by you.

  • An arcpy.Point can be created with just two numeric inputs (ref.)

    # Create point object
    input_x = arcpy.GetParameterAsText(0)
    input_y = arcpy.GetParameterAsText(1)
    point = arcpy.Point(input_x, input_y)
    
  • And finally, the measure variable (presumably being passed in as the Buffer_Unit) should be a string, not a list.

  • Thanks, but I am trying to take this script and add it as a custom tool in a toolbox. I am not sure if I understand. I want it to open up in a dialog box so that I can add the x,y coordinates in their own rows and then have drop downs for the distance of my buffers. When I run the tool I want the point to generate based on the x,y with the buffers. – Wahs14 Sep 23 '17 at 19:24
  • I understand that. What other parts of the process are you needing help with? Based on the two questions you asked above I thought this was all you needed, but I understand how complicated the Python tool creation process can be when you're doing it for the first time! – Erica Sep 23 '17 at 19:26
  • import arcpy import os XY = arcpy.GetParameterAsText(0) outputFC = arcpy.GetParameterAsText(1) buffDist = arcpy.GetParameterAsText(2) arcpy.Buffer_analysis(XY, outputFC, buffDist) – Wahs14 Sep 23 '17 at 19:57
  • I am unable to get the tool to successfully run. It keeps saying that the tool failed. When I go to set the parameters in the tool, I set XY = point, Output FC = feature class and BuffDist = linear unit. I tried to make this even more simple but it is not generating. – Wahs14 Sep 23 '17 at 19:59
  • For BuffDist, you probably want numbers (float, integer) rather than linear unit. – Erica Sep 23 '17 at 20:02

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.