The Toolbox is one of the main ways in which geoprocessing is created within Esri ArcMap Desktop. To this point, tools from existing toolboxes have been employed with Python scripts to do specific tasks. Multiple geoprocessing tools can be used in a single script, but the inputs were provided within the script not queried from the user, thus the script had to be modified each time new data was used. Typically, when a tool is used in geoprocessing in Esri ArcMap the user specifies the input, output and other parameters.
Creating a tool for a personal toolbox will utilize a construction wizard. The process could be directly coded but this is generally beyond the context of this course.
- The format used: arcpy.toolname_toolbox (input, output, etc.)
- The input, output, etc. could be a variable of direct information.
Creating a tool for a personal toolbox will utilize a construction wizard. The process could be directly coded but this is generally beyond the context of this course.
Why Create a Tool
Any user of Esri ArcMap knows that it contains many tools and most are never used for typical operations, so why should the user create personalized tools?
- Many times a user will do similar operations as part of their daily routine, which involves multiple clicks of the mouse, this routine does not have any variation accept potentially the input and output parameters.
- Many redundant processes could be automated, for example if the process is a set of clips after a merge, there is no reason to navigate manually through the tool menus to complete this process, a single tool could do the processes for the user. See the case study at the end of module 4.
- It is very important that proper file naming convention and storage locations be followed to allow for maximum automation.
- As with any Python, script the purpose is to make the technologist more productive and allow for informed decisions, and not be burdened by redundant processes. These processes are time consuming and requires little to no expertise in the process. To design the tool does take extensive thought.
Functions to be Covered
- ToolBox scripting wizard
- GetParameterAsText
- ListFeatureClasses
- Arcpy.describe
- Copy Features
Examples
Example 1:
At the National Geospatial Technology Center of Excellence (GeoTech Center), demographical research requires that specific datasets and geographical shapefiles be joined together for different communities.
- The datasets are always the same type of information, such as median income, educational attainment, race and gender. The feature files are census tract information, but the files represent different regions across the country. In the operation the following are manually done:
- Creation of a new column (field) with a specific data type
- The new field must be populated with data from a different field (this is done to change the format between the two columns, one was numerical and the other is text).
- A tabular join is completed between the spatial file and the spreadsheet that contains demographic information.
- Each time this operation is done manually, the steps are identical.
- The input files and output files contain different information, but the same topics.
Example 2
The GeoTech Center creates regional geographies for two-year colleges.
- Shapefiles are merged together to create the regional boundary, this is usually done both for county boundaries and census tracts.
- The newly created boundaries are used to clip data from state level datasets like roads and rivers.
- The merging and clipping are the same each time, different counties and states are used, thus the input names and the output names vary.