Monday, 21 March 2016

Populating SQL options for parameter in ArcGIS tool?


In ArcGIS Desktop 10 I am trying to create a tool where individuals can select a variety of records using a SQL expression that is then passed to a calculation. I can add a parameter under the tool, and select SQL expression, but when I click on the SQL expression box its not "populated" by potential fields, and therefore unable to get unique values. I thought this might be because the tool needed to know which .shp file it was calling, so I added a higher level parameter to specify the .shp file, but still no luck, the SQL parameter remains entry.



Answer



I was able to get the SQL Expression parameter's dialog to populate by setting its Obtained From property to the input Feature Layer parameter I created:



Script Tool Parameters screenshot Query Builder screenshot


Note that Feature Layer parameters also accept feature classes, e.g. a path to a shapefile or feature class, in addition to the name of a feature layer in the current map document or in the current geoprocessing session. The SQL Expression dialog was populated correctly in both cases for me.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...