Wednesday, August 2, 2017

GIS Programming Module 10: Custom Tools

 This week we learned how to convert a standalone Python script into a tool that can be run like any other ArcGIS tool, which makes scripts more versatile and shareable.

Assuming you've already written a script, the steps to turn it into a customized tool are:
create a new toolbox in ArcGIS > add the script to the toolbox and give it a name/description/etc. > set the tool's parameters > modify the script to allow it to accept user input for the parameters > change any print statements to arcpy.AddMessage (this makes them print to the tool progress window in ArcMap)

Here is the tool window for the script tool from this week's assignment (don't worry about the red Xs; ArcMap is just warning me that those default file paths don't exist on my local computer):


And here is the results window after running the tool successfully:


This was an easy lesson, but an incredibly helpful thing to know, since tools are so much easier to use and share, and better integrated into ArcGIS, than standalone scripts.

No comments:

Post a Comment