Tuesday, July 29, 2014

GIS 4102 Module 10 - Creating Custom Tools

Learning about script tools this module was quite awesome. The use of parameters instead of hard-coded information as is used in stand-alone scripts provides so much flexibility and transferability of the script. Another advantage of script tools over stand-alone scripts is that message statements which are written to a progress dialog box and the Results window can be in a script tool. This allows the retrieval of results messages at a later time. Stand-alone script messages are printed to the interactive window and cannot be retrieved later. While the use of stand-alone scripts requires some knowledge of Python, the use of script tools does not require knowledge of Python. The script tool's dialog box is a convenient way for users to enter parameters with validation and error-checking included. The script tool window for this assignment is shown here:
Script Tool Window Showing Parameters Ready for Input
Even the creation of a script tool is relatively easy. After verifying that the stand-alone script forming the basis of the script tool works properly, a new script tool is added to a toolbox in ArcMap's Catalog. The new script tool is given a name, label, description, script file, and so on before parameters are added. After properties for each parameter are set, the original stand-alone script is edited to replace hard-coded filepaths or file names with the applicable parameters from the script tool. Print messages in the stand-alone script are replaced with message statements. This image shows the messages after running the tool for this assignment:
Resulting Messages from a Script Tool Which Clips
Several Layers to a Single Feature
Once the performance of the script tool has been confirmed, the script and toolbox containing the script tool can be zipped together into a folder. VoilĂ ! It's ready to share with anyone else. Just for fun, I emailed the zipped file to myself and used it with some other data. Here's an image of Orange County, Florida, with roads and some other features clipped to the county line...another demonstration of the incredible functionality and adaptability of Python scripting:
Orange County, Florida, with Features Clipped Using Script Tool

No comments:

Post a Comment