I want to create a custom tool so users can provide input for arcpy.Select_analysis(in_feature, out_feature, where_clause).
This is the line I want to change into a form for a custom tool:
arcpy.Select_analysis("C:/Birds/Data/nso.shp", "C:/Birds/Data/active.shp", """"NEST" = 'active'""") #NEST is the attribute table field and active is an attribute.
But I want a custom tool so the user can input there own values.
I can properly code for the in_feature and out_feature variables using arcpy.GetParameterAsText.
I need help with the where_clause.
Here is some of my code:
inFeature = arcpy.GetParameterAsText (0) #variable for user to input feature
OutFeature = arcpy.GetParameterAsText(1) # variable for the output feature
FieldForSelect = arcpy.GetParameterAsText(5) #user inputs field in attribute table to select features
AttributeForSelect = arcpy.GetParameterAsText(6) #user inputs attribute to select for.
Would the code be
ActiveNest = arcpy.Select_analysis(inFeature, OutFeature, """"FieldForSelect" = 'AttributeForSelect'""") ?
My second question is what is the data type for FieldForSelect (Is it Field?)?This is a field in the attribute table.
And what is the data type for the actual attribute AttributeForSelect (Is it String?)? I think it is string since the attribute is a word/string.
From my example the field is NEST and I am selecting for "active".
Thank you.