Wednesday, August 9, 2017

GIS Programming Module 11: Sharing Tools

This week was focused on different ways of sharing custom script tools for ArcGIS, and for the assignment we were provided with a script tool and asked to make some updates and then embed the script in the tool. This allows the toolbox to be shared without the separate script file, and also allows the creator to password-protect the script so that other users can't copy or edit it.

The script tool was already partially functional, but needed some hard-coded variables to be replaced with coding that accepts user input from the tool interface. Then we needed to add descriptions for each of the tool parameters, and finally embed the script in the tool and set a password.

This screenshot shows both the tool interface and the output of an example from the lab using 50 points and distances of 10000 meters:



This is the last week of class, and I've had a great time and learned a ton. The most exciting and immediately useful thing I learned during this course is how to write geometries using a Python script, which I used in my final project to solve a real-life problem. I also found the lessons on turning a model into a script and turning a script into a custom tool to be very interesting, and I already have plans to apply those concepts outside of class as well. I also think it’s very cool that you can use Python scripts to manipulate GIS files and even map documents without ever even opening ArcMap.

Wednesday, August 2, 2017

GIS Programming Module 10: Custom Tools

 This week we learned how to convert a standalone Python script into a tool that can be run like any other ArcGIS tool, which makes scripts more versatile and shareable.

Assuming you've already written a script, the steps to turn it into a customized tool are:
create a new toolbox in ArcGIS > add the script to the toolbox and give it a name/description/etc. > set the tool's parameters > modify the script to allow it to accept user input for the parameters > change any print statements to arcpy.AddMessage (this makes them print to the tool progress window in ArcMap)

Here is the tool window for the script tool from this week's assignment (don't worry about the red Xs; ArcMap is just warning me that those default file paths don't exist on my local computer):


And here is the results window after running the tool successfully:


This was an easy lesson, but an incredibly helpful thing to know, since tools are so much easier to use and share, and better integrated into ArcGIS, than standalone scripts.