Friday, August 7, 2015

GISProgramming: Module 11 - Sharing Tools

     I dabbled in the previous modules with sharing a zipped file of a toolbox containing tools/models. This module took sharing tools a step further by introducing additional ways of sharing, not only using a zipped file but sharing over a LAN or with ArcGIS Server (beyond the scope of this course). For this assignment we zipped our data because we neither share a LAN nor do we make use of ArcGIS Server. I practiced preparing files and creating tool documentation for a shared tool called the Random Buffer Tool. This tool takes a bounded feature and generates random points within it and surrounds those points with a buffer. A screenshot below shows the tool interface. Programming the parameters is discussed below. 
     Providing help documentation is beneficial to the user of your tool. This is accomplished through editing the Item Description in ArcCatalog. Once sufficient detail for the tool is provided the tool can be prepped for sharing. It is recommended that the script be embedded in the tool and protected against tampering with a password. 


sys.argv[] versus gp.GetParameterAsText 
     The script for the tool had to be modified to remove hard coded paths. This serves as an example or cautionary tale for sharing a script tool. Hard coded paths do not or may not exist on the computer of the person(s) you shared the tool with thus necessitating their replacement. Those file paths are replaced with lines of code accepting user input (their designated file paths and workspaces). This is done using sys.argv[] or the gp.GetParameterAsText(). The latter code is preferred as it possesses no character limit. Older scripts make use of the former so it is useful to know how it functions as well. Both use parameter index numbers differently, sys.argv[] begins indexing at 1 (because 0 indicates the script itself) while gp.GetParameterAsText() begins indexing at 0. For the code to run properly it is important that the parameters in the tool dialog box are called correctly by their index number in the script.     

Tool interface. While it currently shows a description of what the tool does,
clicking in the parameters provides a description as well (inArcGIS). 

A screenshot of the result of running the Random Buffer Tool.
It shows a bounded region containing random points with surrounding buffers. 
     This is the last post for Python programming with GIS. This past semester has flown by and I have learned not only about how to automate geoprocessing tasks but about myself. I can code. I can learn code and implement code and I am confident that I can understand other programmer's codes, debug my code, and compose new code. I am also comfortable seeking out help through classmates/colleagues or outside forums.
     When I started the certificate program I joined a GIS listserv. After this programming course I feel comfortable engaging the GIS programming community on the listserv. Hopefully I can make someone's day, and mine, by helping solve a coding issue and continuing to grow as a programmer and GIS practitioner. Thanks for following.