Thursday, June 11, 2015

Module 5 - Geoprocessing in ArcGIS

This week we brought the geo back into the processing and learned about how geoprocessing tools, models, and scripts work within the ArcGIS environment. I've been using geoprocessing tools throughout the program and we touched on ModelBuilder and arcpy last semester, but this time we looked at each with respect to the underlying script.

The assignment included making a model in ModelBuilder then exporting it as a script and finally creating a script tool from it. To make the model I first had to create a toolbox, set my workspace environments, and enable the overwriting of outputs for geoprocessing operations. This is usually off, but with models and tools, it is more effective to have it on as I can then rerun a tool without having to change file names each time. For my model, I was tasked with clipping a set of input shapefiles, making a selection from the output, and then erasing that selection from one of the initial inputs. After setting the inputs and outputs as model parameters and ensuring it ran the way I wanted, I exported the model as a script.

The script initially had errors as it was created within ArcMap and needed a few code adjustments to function as a stand-alone script. After some file path adjustments and the addition of a line of code to allow the script to overwrite the geoprocessing outputs (just like in ArcMap, but it has to be respecified in the script), the script ran correctly. From there I added the script as a new tool in my toolbox and tested the script to be sure it created the correct shapefile, as seen below.

I like the visual aspect of ModelBuilder and seeing the code behind the tool. Definitely have to keep an eye on the details when building a model, but that's no different then writing a script, and as always, it is very rewarding to see the final smooth running of results.

Screenshot of basin with specified soil types erased out as the results of a script tool based off of a model. 

No comments:

Post a Comment