Friday, July 31, 2015

Module 10 - Creating Custom Tools

This week finishes up Module 10 in GISProgramming which means only one week left! This week the focus was on creating a custom tool in ArcMap based off of an existing stand-alone Python script. I haven't worked on Module 11 yet but I think this might be the most useful part of the course granted this section would not be possible without all of the background knowledge I have now.

For the lab we were given a stand-alone script and the direction for turning it in to a script tool in ArcMap. The script tool we created clipped multiple files to the same boundary area at one time. This is my very general description of how to create a script tool:

Multi-Clip Script Tool
1.       Create stand-alone Python script that performs geoprocessing within ArcMap. 
2.       In ArcMap create new Toolbox in the desired folder in the Catalog window (the same folder the script is saved in).
3.       Add a new script tool to the new Toolbox. This will open the new script tool window.
4.       Set the name, description, store relative paths option, and file path to the stand-alone script in the new script tool window.
Script Tool messages printed to the Results window in ArcMap
5.       Set tool parameters for the script tool either in the script tool wizard or in the script tool properties.
6.       Edit the stand-alone script to reflect the tool parameters set for the script tool instead of absolute paths with the arcpy.GetParameter() code.

7.       Within the stand-alone script change print statement to arpy.AddMessage() statements so the messages will print in the Results window in ArcMap.

By setting the parameters, in both the tool and the original script, you can turn a script that processes on set of data into a tool that can run a particular process on lots of different data (as long as it is the same data type).Knowing how to build these tools would have made GIS Applications labs a little easier and quicker to work through.



-A note for the final project-
I forgot to add updates about my final project the last few weeks. I decided to work with a large .csv containing crime data points that I downloaded from the San Diego Regional Data Warehouse for my Applications class. There was way too much data to work with in ArcMap initially so I wrote a script to display to the points, save the points as a feature class, clip to points to a particular buffer zone, and then separate the points by year. I presented the script project this week in GISProgramming and I'll be working with the data this weekend to finish my analysis project for Application.

No comments:

Post a Comment