Professional Documents
Culture Documents
We'll start our look at programming tools by exploring the geoprocessing framework, and learn what we can do with ModelBuilder, a tool for creating a flow chart of a process. Model Building is good for many geoprocessing tasks, and provides a visual way to design our geoprocessing tasks. For many tasks, this may be all we need. And after we explore scripting, we'll find that using ModelBuilder and Scripting together works better than either method on its own.
Slide 2
Most of GIS work is data management. Data analysis and modeling is more interesting. We have to do both. So learning multistep geoprocessing methods lets us both do the interesting stuff using multiple scenarios, or do the boring stuff by letting the computer run each step in succession. The idea of a model isn't new with ModelBuilder. Developing models is a major part of scientific research, where one might try to predict a phenomenon with collected data often involving statistical probabilities. Coding a model is what we're doing here, and might involve a model developed by other studies, either done by yourself, colleagues, or published in a research journal.
Slide 3
AML Model
Something like a site suitability model might involve application of a weighting scheme applied to input datasets and field values, in order to predict an output input data. This can be done in a script, such as with AML or Python, where each statement might process an input into an output; successive statements might take those previous outputs as inputs, and lead to new outputs, and so on
Slide 4
ArcToolbox
Access to system tools, scripts and models
Each can be run by double-clicking Each can be used as a step in a model Models and Python scripts can be edited
Right-click script Edit
The ArcToolbox is organized by toolboxes, each of which might contain toolsets. Includes system tools, scripts, and models. Many tools come with the software, but you can add your own toolboxes with scripts and models. There is also a new command prompt; I don't see its advantage. The commands are longer in format, thus harder to remember. I would tend to only use tools in python scripts or modelbuilder.
Slide 5
We'll explore geoprocessing tools in the next section. For now, just note that geoprocessing tools can also be accessed here.
Slide 6
ModelBuilder
Runs from ArcMap or ArcCatalog. If from ArcMap, layers from the map can be used as input. Models are created and stored with ArcToolbox. ModelBuilder is very easy to understand in that it is visual. You do need to be careful in using it, because some tools can be tricky to use especially the reclassify and weighted overlay shown here. The various elements of a model are input datasets (blue ellipses), input variables (light blue ellipses), processes (yellow rectangles that might be system tools, models or script tools), output datasets (green ellipses they can also be used as inputs), labels, connectors with arrows showing what goes where. The little "P" indicate model parameters we've selected to use as model inputs and outputs. Coloring: If your model elements are not colored in, they aren't ready to run. Shadows: After you've successively run part of the model, that part will have shadows underneath the elements. In this figure, nothing has been run yet.
Slide 7
Dataset Inputs
Layers (yellow polygons) Model Elements (blue)
Note the elements that are shadowed, meaning they've already been run.
Variables
Numbers, etc., shown as cyan ellipses
Note that the same dataset may be both an ArcMap layer and a model element. Choosing which one depends on how you want to use it, and should make sense for your use of the model. Using the connector line is another option, but you can't control which parameter you're providing with it, so I would check its result by opening the process anyway. Some tools only have one input, so you can probably get away with it there.
Slide 8
To re-run the model, you need to use File/Validate Entire Model to re-initialize it.
If you don't run a previous step first before you try to reclassify the results, the reclassify tool won't know what it's trying to classify. This is important not only for reclassifying, but also for the weighted overlay, which includes a kind of classification itself. You'll see this especially if you're trying to use weighted overlay with text fields, derived by a previous reclassification. It doesn't know what that field is or its value until a previous step has been run. Submodels should also be run before they are use. Once you've gotten all of your processes run, and have completed the entire model, you can change any of the inputs and run the whole thing again. Re-running a model with new inputs allowing you to test the effect of variations in those inputs is an important part of modeling.
Slide 9
ModelBuilder can work with system tools (hammer icon), script tools, and other models. We'll learn how to create script tools later. If models are used inside other models, input and output parameters are going to be important to define. One way of learning how to use geoprocessing tools in python is to create a simple model that uses them, then export the model to a script.
Slide 10
Model Parameters
For processes in ModelBuilder, you can define inputs and outputs as Model Parameters.
Purpose is to allow a model to have inputs and outputs Especially useful for submodels, which might have an output model parameter that becomes the result of the model, just as a system tool creates a result. Think of a model as a filter, with inputs and outputs.
Model parameters are especially important when using models inside other models. In the next section of the class, we'll learn how to write scripts in Python. Then we'll learn how to make these scripts work as script tools, so we can run them from either ArcToolbox or ModelBuilder. One of the things we'll need to define in the script, then in the script tool, are input and output parameters.