GIS Blog

Flow Diagrams That Work

We cover executable flow diagrams using ModelBuilder in this post.

In a previous post we covered a straightforward example of a quick GIS job that involved Merging and Dissolving 43 input contour shapefiles, then selecting and exporting a subset.  At the end, I flippantly included a flow diagram, reproduced by the magic of science below:

I’m a great advocate of using flow diagrams in GIS.  The one above is serving as a nice visual summary of the steps taken in this analysis.  In the tradition of a picture telling a thousand words, the flow diagram can often replace a long, drawn out text description to better tell the story.  I frequently see them in theses and journal articles doing just that.  But they also work well in the planning stages of a GIS analysis project.  I will often use flow diagrams before I even open up ArcMap to help organise my approach and the tools I’ll use.  They are subject to change, of course, but they often serve as first drafts of what I might end up doing.

The nice thing about the one shown above is that it’s more than just a pretty picture: it works – it’s executable.  Rather than work with Word or Visio to painstakingly put together a bunch of boxes, ovals and arrows, I built the diagram above using ModelBuilder inside ArcMap (or ArcCatalog).  In short, any geoprocessing tool available in ArcGIS can be dragged on to a blank canvas and used to build up an analysis flow.  I’ll show you a few quick examples of how to build up a model and then add in a video at the bottom to show how it all fits together.

Adding tools to ModelBuilder

Open a new model from ArcMap or ArcCatalog by clicking on the ModelBuilder button, , on the Standard toolbar.  This open a new, blank canvas.

Here’s where you’ll build up the model.  Geoprocessing tools from ArcToolbox can be dragged onto the canvas.  In this example from that previous post, I’m working with 43 input shapefiles of elevation contours lines that I’ll merge together.  To simplify the merged contours I’ll then run the dissolve tool, then run a query to select a subset of those records, and finally export those selected records (see how much easier it is to explain that with a diagram?).  So let’s start by dragging the Merge tool onto the canvas.  The Merge tool lives in ArcToolbox > Data Management Tools > General toolset – that’s open at the right.  All I need to do is click on it and drag it onto the canvas:

Next I’ll set the parameters for the tool by first clicking somewhere on the canvas to clear all the selected features and then double click on the Merge tool, opening its tool window:

Notice that I’m using 43 shapefiles as an input so what we see on screen is probably going to be a bit messy.  When I click okay you can see how the diagram changes:

Those blue things are all my input shapefiles so I’ll just zoom in on the main tools:

With the tool parameters set, the colours of my boxes have changed.  The blue ovals are my inputs, the orange boxes are tools and the green ovals are outputs.  This is now an executable model, albeit a simple one.  If I wanted to, I can click the Run button, , and the tool will run but we’ll do that after the whole model has been built up.

Next we’ll add the Dissolve tool.

I want to use the Merge output as the input to this tool.  As with the Merge tool, it’s initially blank so first I’ll link the Dissolve tool to the Merge output using the Connect tool, , – this just means clicking on the MergedContours.shp oval and dragging a line to the Dissolve tool.  When I connect to the Dissolve tool, a small window pops up that allows me to set the nature of the connection:

Here I want to use the Merge tool output as the input to the Dissolve tool so clicking “Input Features” makes this happen:

Just to ensure that the tool is set up okay, I’ll double-click on Dissolve to check it:

Ticking both the attributes just ensures I keep them in the output.  That tool’s now set so we can move on to the query and the export.   I’ll skip ahead but you can see all the action in the video below.  My final model looks like this:

Those paying attention may note that this diagram is a little bit different from what I first showed at the top.  The last tool used is Select without the Copy tool at the end.  I hadn’t realised when I first set this up that the Select tool creates its own output so my final model is even simpler.

With this final step I now have not just a pretty picture (subject to debate) but now an executable model that will take the inputs, run the tools and deliver me an output. And it works!  Clicking the Run button ran the model and overall it took about 2 minutes to run and delivered this as a result:

So ModelBuilder allows us to graphically build up a model by dragging and connecting tools on a canvas.  Parameters and tool settings can be set in advance and when all it tickty boo, the model can be run in the background.  In addition to creating working flow diagrams, it can be a great time saver in the right circumstances.

To be fair, this example shown here is probably not one where i would actually use ModelBuilder, but it served well as a good simple example of how it could be used.  The balancing act is often around a question like: Am I going to spend as much (if not more) time building the model as I would just doing it manually?  If something like this is to be a time saver then it has to speed up the whole analysis process.  For something like this, I suspect it wouldn’t really be worth my while to build the model that I might only use once.  Models are most useful when you’ve got a complex set of tools that need to run and rerun multiple times.  Or, if you’ve got a lot of data layers that need the same thing done to them and doing so would either drive you insane or blind.  It’s probably not worth it for one off tasks unless there’s the possibility of having to do it another time in the future or if running the tasks is going to take large amounts of mindless time.

Of course the other alternative to this is Python scripting.  There have been a number of previous posts on the use of Python (here, here and here, and a few more on the way), and ModelBuilder offers an alternative for those who don’t (or don’t want to) write script.  In fact, all ModelBuilder is is a nice visual interface for creating Python scripts.

For those of you interested in the gory details (and you know who you are), the video below shows the whole process of building up and running this model.

C

 

 

 

 

• May 3, 2018


Previous Post

Next Post

Leave a Reply

Your email address will not be published / Required fields are marked *