Python Script Tool

A Python script tool lives within a custom Python script toolbox. A Python script toolbox differs from other “custom” toolboxes such that a “custom toolbox” could have ModelBuilder models or other existing geoprocessing tools within it or a Python script can be associated with a “custom tool” within a custom toolbox. The latter is not preferred and if any “non out-of-the-box” functionality is required and an “easy-to-use” interfaced is needed, then the Python script tool is the recommended choice. A Python script tool is already apart of a Python script toolbox and all of the code exists within the Python toolbox (i.e. .PYT) format. This .PYT file is easy to edit and update with a simple “right-click” on the toolbox. Changes are saved, then the tool can be tested and used.

The Python script tool is considered a more advanced use of Python and ArcGIS, since the script creator and user may not require a user interface and the stand-alone Python script is sufficient. For those that have the programming and/or science, math, statistics, etc background and want a simple user interface for others, then a Python script tool is a good alternative to a stand-alone script.

The author recommends developing the logic, script, and thorough testing of the script before embarking on the Python script tool. The tool development itself can require significant time and additional research with ESRI help documents, terminology, and methods.

See the Chapter 10_12ScriptsandData.zip file to find the Python_Functions_Custom_Toolbox.ppkx pro package file containing the Tasseled Cap Python script tool.

Tasseled Cap Python Script Tool

The following videos review the overall processes to develop the Python script tool for the Tasseled Cap image processing routine that is typically used with Landsat 4, 5, and 7 imagery. Tasseled Cap coefficients are only developed for specific satellite sensor platforms and is cannot be used with all kinds of raster imagery. Pro now has a built-in Tasseled Cap routine, so creating this tool for one’s own use isn’t warranted; however, this process serves as a good working example of what one needs to go through to create a Python script tool.

Tool Overview and Initial Set Up

Set up Tool Parameters

Other Tool Functions

Set up the Execute Function and Other Commentary