Creating Script Based Tools
Introduction & Learning Objectives
In our last lesson, we built a Python-based geoprocessing workflow using ArcPy. The result — a Jupyter Notebook that combined the IBTrACS storm archive and U.S. county features — produced a feature class and summary statistics for a single storm season and name. Along the way, we learned how to structure code clearly and make our analysis reproducible and adaptable.
That product met the goals of reproducibility and transparency: our code and its products were plain to see. And it was somewhat useful as a tool in that we put the inputs to the analysis toward the front of the notebook such that the storm season, storm name, and output feature class were relatively easy to locate and modify. However, if our goal is more to creating a useful tool from our code, we can do much better by giving it an interface, and ArcGIS Pro allows us to give it that interface, which will be the focus of this tutorial.
Learning Objectives
- Convert a notebook to a Python script
- Convert script variables to model inputs
- Debug a script with model inputs
- Create an ArcGIS Pro interface for a model input
- Add messages, errors, and warnings to your script output
- Create a validation script for an ArcGIS Pro script based tool
- Package and distribute a workspace with model based tools
Task 1 - Workspace Setup
We’ll be doing a bit more work in GitHub in this lesson and also leverage our existing hurricane mapping Jupyter notebook in writing our code (since most of the work is already done there).
1.1 - Fork the class GitHub repository
1.2 - Clone your forked repository to your local machine
1.3 - Prep the workspace
- Unzip the IBTrACS_NA.zip file
- Convert your notebook to a Python script & tidy.
- Note the
.gitignore
file
1.4 - Stage, commit, and push changes
Task 2 - Enable inputs to your Python script
2.1 - Change variables to inputs
- Storm season
- Storm name
- Output feature class
2.2 - Test your code
- Create your .vscode/json file
###