I am trying to write a python script and create a script tool in ArcGIS that will let a user choose the value or values that will be used to extract a shapefile. These selected value(s) will then need to pass through the select tool. I'm sure this involves writing a WHERE clause but I'm new to python and am a little lost on this one.
|
EDIT: Ok, I took another swing at it now that I think I have more of an idea of what you're looking for. It isn't perfect, as you can't select specific existing values, but you CAN select a field and enter as many values as you want into the query. Here's the code:
When you set up your parameters, make sure that the field parameter is 'obtained from' "input". Also make sure you select "yes" for multi value for the values parameter.
This will give you something very similar to the example you linked to. I'm sure the query building could be done a better way but my brain is fried. Let me know if this is more along the lines of what you were looking for. |
|||||||||||||||||
|
The following arcpy-based script which uses select layer by attributes is a good starting point. I retrofitted the script to work as a script tool in ArcGIS. You can easily substitute polygon FCs for point FCs in the Select Layers section to tailor the script to your specific needs.
Using the following parameters: In this test example,the output includes only the points 1) within the polygons and 2) with "OBJECTID" > 50. |
||||
|
OK - so this is what I've come up with so far. It kind of works. Its going through the whole process but only giving me back the first county that I list as an argument. For example, when I type in county names in the arguments dialogue box I've tried typing it "ASHE";"AVERY" as well as "ASHE" "AVERY" and the script only takes in ASHE. I'm assuming this might be a syntax issue? Here is my current code:
|
|||
|