Clicked-point coordinates as input for buffer tool in python (outside ArcMap)

11-12-2015 09:30 AM
Occasional Contributor III

I'm looking build a custom geoprocessing service to be added as a widget in Web App Builder.  The geoprocessing tool will need x/y coordinates from a clicked point on a map (not a point from an existing feature class).

I'm working outside of ArcMap (coding in Pyscripter , so my understanding is that a Python add-in may not work).

For simplicity's sake, let's say it's a buffer tool - easy enough w/ arcpy, but my question is how to use x/y from clicked point as input for the buffer.


0 Kudos
7 Replies
Esri Contributor

Hi Allen, though you can use python to do this, based on what I'm reading, it might not be necessary. You should be able to create this scenario in Modelbuilder. You would add the buffer tool to your model, and then create a new "Feature Set" variable to the model and set. The Feature Set variable type is an interactive, user-input type.


Then set this new parameter as the "Input Features" parameter.


So we've established this "Feature Set" parameter as our input geography parameter for the buffer tool. Now we'll want to tell the Feature Set parameter what kind of geography to allow. Right-click on the feature set parameter > Properties, and import the schema and symbology from another layer or feature class. This is handy. This allows you to control what the symbol looks like as the user drops it, and it also allows you to control what kind of geography they input: points, lines, or polygons.


More than likely, I imagine you'll want to allow the user to adjust the size of the buffer rather than hardcoding it. You can make that a variable in this model by right-clicking the buffer tool > make variable > from parameter > Distance.


Now we want to make sure that both of these new parameters are flagged for requiring user input. Right-both of them and make them model parameters.


For sake of argument, go ahead and set the output of the buffer tool to something like in_memory\out_buffer. Now save this model in a toolbox. Once it's saved, double-click on it to launch it like a tool. You'll now have a tool that allows you to manually drop an input point, specify a buffer size, and it'll create that buffer.


Now from here, you would publish this as a geoprocessing service and hook it up in the Web AppBuilder with the Geoprocessing widget. You'll be able to experience the same interactivity  there.

Occasional Contributor III

Since the intent of the buffer model is to be used in Web AppBuilder for ArcGIS, which would use Web Mercator, how would you properly define the coordinate system of the model?

I've set the model up several different ways, including the use of Web Mercator, but the measure tool in Web AppBuilder from input centroid to buffer ring does not return the actual input buffer value. However, when you run the model in ArcMap (with the data frame in Web Mercator), the ArcMap measure tool does measure as expected.

I know it's related to coordinate systems/projections-- but is the issue actually with the measure tool in Web AppBuilder or does the model need adjusted?

See image. This is a 5 mile radius buffer, however it does not read that way in Web AppBuilder:

0 Kudos
New Contributor III

Hi Cole,

Were you able to fix the issue. Even after so many years, I am facing the same issue. 😄

Any insights would be helpful.



0 Kudos
Occasional Contributor III

Dennis, thank you for outlining the steps for publishing a buffer model as a Geoprocessing service. I have one question. When I go to configure the new Geoprocessing widget via Web App Builder for Developer v1.3 I cannot get the the "Add result as operational layer" to become active, this option is grayed out. I tried a couple different options with the service through ArcGIS Server but I cannot seem to activate this option. Any suggestion on what properties need to be defined within the Model or Service so that this option is available?


BenGeoprocessing Options.png

0 Kudos
Occasional Contributor

Ben, when you publish the GP service, check the option in the Parameters tab to 'View results with a map service'.  This will publish the buffer result as a map service after every run and then you will be able to select 'Add result as an operational layer' in WebApp Builder.  Set your symbology of the buffer before you publish the service, the symbology will be honored in the result service.

New Contributor III

I've tried to follow the steps outlined here and I get the same grayed out option for the "Add result as operational layer".....I can't check the box - it's grayed out !

Thank you


0 Kudos
Occasional Contributor

Make sure you set an Output parameter in you script/model.  Set it to derived, and add to display.  See picture for ModelBuilder example.