There are two ways to create toolboxes in ArcGIS: script tools in custom toolboxes that we covered in the last recipe, and script tools in Python toolboxes. Python toolboxes were introduced in version 10.1 of ArcGIS and they encapsulate everything in one place: parameters, validation code, and source code. This is not the case with custom toolboxes, which are created using a wizard and a separate script that processes business logic.
A Python Toolbox is similar to any other toolbox in ArcToolbox, but it is created entirely in Python and has a file extension of .pyt
. It is created programmatically as a class named Toolbox
. In this recipe, you will learn how to create a Python Toolbox and add a custom tool. After creating the basic structure of Toolbox
and Tool
, you'll complete the functionality of the tool by adding code that connects to an ArcGIS Server map service, downloads real-time data, and inserts it into a feature class.