I am looking to create a user-input script for finding surrounding features of a given point. However, the parameters for it are very sensitive and I would like for it not to have to be such a process to create results.

This is the script that I have so far:

import arcpy
import sys

inFc = sys.argv[1] #input feature class (for some reason must be shapefile because the feature classes in a geodatabase don't have FIDs
nearFc = sys.argv[2] #near feature class for near table analysis (feature  class)
outTable = sys.argv[3] #output table for near table analysis, also used as input for field name change so that the "IN_FID" field changes to "FID" to match the input and so the selection can be performed (table parameter)
distance = sys.argv[4] #search radius for near table analysis
outLyr = sys.argv[5] #X/Y event layer so that the near table analysis can be presented on the map
projection = sys.argv[6] #projection for the x/y coordinates
selId = sys.argv[7] #Query expression obtained from input feature class so the user can choose one feature from the input to highlight all the surrounding near features from

arcpy.GenerateNearTable_analysis(inFc, nearFc, outTable, distance, "LOCATION", "NO_ANGLE", "ALL", "", "GEODESIC")
arcpy.AlterField_management(outTable, "IN_FID", "FID")
arcpy.MakeXYEventLayer_management(outTable, "NEAR_X", "NEAR_Y", outLyr, projection)
arcpy.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", selID)

As you can see, there are too many parameters and it would not be easy for a user to perform this quickly for a demonstration. Taking into consideration my comments, are there any possible ways that this could be streamlined and adjusted?

  • 3
    Create a default value for all parameters, then the user can just hit the OK button. Dec 4, 2017 at 20:38
  • Geodatabase feature classes have an OID not a FID, you can get which from a describe object: d = arcpy.Describe(inFc) OIDfieldName = d.OIDFieldName resources.arcgis.com/en/help/main/10.2/index.html#/… from there your query becomes '{} = {}'.format(OIDfieldName,selID). If you're not keeping your table you can make up a path, apart from that they look all required. Dec 4, 2017 at 20:40
  • 3
    I second @Mattropolis comment. If the parameters are all required as they represent how someone would use the tool, just provide default values so you can run it "quickly". Tie the tool to a map document with your layers loaded in the ToC and set the layers as default input.
    – KHibma
    Dec 4, 2017 at 20:40
  • @Mattropolis, sounds like an answer
    – artwork21
    Dec 4, 2017 at 21:10
  • @Mattropolis I set the defaults and it helped a lot. Thank you so much! Dec 5, 2017 at 15:03

1 Answer 1


To make it easier for the user, create a default value for all parameters, then the user can just hit the OK button.

In the script tool properties, create a default value for all of the parameters. Right-click the script in the Toolbox, click Properties. Select the first parameter, then put an appropriate value in the Default property.

In the attached example the 2nd parameter has a Default value for the Output Location. The first doesn't have a default. Having a default parameter doesn't prevent the user from changing them.

enter image description here

  • Thank you, I am about to try this. I can't seem to set a geodatabase as a default though. Folders won't allow the .gdb extension Dec 4, 2017 at 21:35
  • Try changing the Data Type to Workspace Dec 4, 2017 at 21:43

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.