the results of the script execution by examining the data in an ArcGIS for

The results of the script execution by examining the

This preview shows page 48 - 50 out of 335 pages.

the results of the script execution by examining the data in an ArcGIS for Desktop application. There are several benefits to running a script directly — most notably, you can set a script to run at a specific time without user intervention. Another way to run a script is to use a Python editor like PythonWin. You can open a script in the editor, verify its content, and then execute the script. Similar to running a script directly from the operating system, you do not need to have an ArcGIS for Desktop application open for the script to run, although you need to have ArcGIS installed on your computer to be able to use the geoprocessing functions. One of the benefits of running a script using a Python editor is that messages are printed to the interactive window, including any error messages. The third way to run a script is to create a script tool that runs the script. For example, you can create your own toolbox, create a new script tool ( for example, My Clip Tool ), and then add the clip_example.py script to this tool. You can then run the script as you would any other geoprocessing tool. The benefit of running a script as a script tool from within ArcGIS is that you can integrate the script tool with other tools and models. The tool has its own dialog box, and the tool can be added to a model in ModelBuilder or called by another script. The script used here so far is relatively simple and in fact does noth- ing more than the regular Clip tool. However, it is relatively easy to create scripts whose functionality exceeds that of existing tools — these scripts are covered in later chapters. 2.11 : Running scripts as tools As discussed in the previous section, scripts can be run in various ways. Running a script as a tool is a great way to integrate Python scripts into ArcGIS workflows. In fact, many scripts written by Esri are made available as tools in ArcToolbox. For example, take a look at the Proximity toolset within the Analysis toolbox. Notice that the Multiple Ring Buffer tool is a script tool, as shown in the figure.
Image of page 48
Chapter 2: Geoprocessing in ArcGIS 2.11: Running scripts as tools 42 When you open the tool dialog box, it looks like a regular tool with several required and optional parameters. So from the perspective of a regular ArcGIS user, all tools in ArcToolbox look the same. For most system tools in ArcGIS for Desktop, the underlying code cannot be viewed. However, for script tools, you can look “under the hood” by open- ing the script. To view the contents of a script, right-click the script tool and click Edit. This shows that the tool calls a script called MultiRingBuffer.py. These scripts are typically located in C:\Program Files\ArcGIS\Desktop10.1\ ArcToolbox\Scripts. Several dozen of the system tools that come with ArcGIS for Desktop are script tools, and their content can be viewed in this manner.
Image of page 49
Image of page 50

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture