I’ve been trying to solve this one for a couple of days, so any help would be greatly appreciated!
I have created a Script Tool to perform the following tasks:
- Buffer the selected features, using arcpy.Buffer_analysis
- Select the features that intersect the buffer, using arcpy.SelectLayerByLocation_management, and add them to the existing selection
- Return two output parameters (the Buffer and the new Selected Features) as Feature Layers
The Script Tool code is below:
# Get input parameters
inputFeatureSet = arcpy.GetParameterAsText(0)
bufferDistanceMetres = arcpy.GetParameterAsText(1)
# Create buffer
outputBufferLayer = arcpy.Buffer_analysis(
# Select intersecting features
outputFeatureLayer = arcpy.SelectLayerByLocation_management(
except Exception, e:
# Set output parameters
The parameters are configured as follows:
|Display Name||Data Type||Direction|
Ultimately, I need to call the GP Service from the Geoprocessing Widget in Web AppBuilder. The Script Tool works fine in ArcMap, but when I publish it as Geoprocessing Service, it fails in SelectLayerByLocation_management with the following error:
Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.
Failed to execute (SelectLayerByLocation).
The error is because SelectLayerByLocation_management expects a Feature Layer instead of a Feature Set. However, the Script Tool input parameter must be a Feature Set in order for the user to be able to select a layer in the Geoprocessing Widget. If I try to create a Feature Layer from the Feature Set, only the originally selected features are included (instead of all features), so the selection cannot be added to when intersecting with the Buffer. Including the InputFeatures as an additional input parameter with type Feature Layer could work, but I don't believe that's possible because it would also have to be selected by the user.
Besides creating a custom widget, does anyone know of a way to do this?