Model Builder at ArcGIS 9.1

advertisement
ModelBuilder at ArcGIS 9.3.1
Lyna Wiggins
May 2010
Python and ModelBuilder
ArcToolbox in ArcGIS
Continuing
Education
Python and ModelBuilder
Creating a New Toolbox
• Create a new Toolbox in ArcCatalog or ArcToolbox.
Default location for a New Toolbox created inside
ArcToolbox is:
– C:\Documents and Settings\<user profile>\Application
Data\ESRI\ArcToolbox\My Toolboxes.
• If you will be sharing your model and using relative
addresses, you need to plan the folder location of
your New Toolbox carefully.
• Create a new Model by a right click on the new
Toolbox.
Continuing
Education
Python and ModelBuilder
Geoprocessing Tools
• There are five ways of using geoprocessing
tools in ArcGIS:
–
–
–
–
–
Run (some of) them in ArcMap
Run them from ArcToolbox
Type them at the command line
Use them in a script environment (like Python)
Use them in ModelBuilder
Continuing
Education
Python and ModelBuilder
What do we want to do?
• We might want to use a series of geoprocessing tools
in an exploratory analysis.
• As we explore, we want to visualize our results as we
work.
• We might like to change parameter values and see
their impact.
• ModelBuilder is helpful in this exploratory process.
Run processes as you go – you may not even want to
save the model.
Continuing
Education
Python and ModelBuilder
What do we want to do?
• If you have a complex sequence of processes that
you have to do frequently – or with a number of
different datasets – you will want to create and save
a model.
• You may want to:
– run multiple scenarios – for example, for a build-out
analysis,
– create custom tools and use them inside your model or by
themselves,
– share your model with others.
Continuing
Education
Python and ModelBuilder
ModelBuilder
• ModelBuilder is integrated throughout the ArcGIS
product lines – any tool in Toolbox can be used to
define a process. These include tools from the
Extensions.
• ModelBuilder helps us create, edit, document and
distribute models.
• After you create a model it can be exported as a
script (to Python, for example).
Continuing
Education
Python and ModelBuilder
ModelBuilder
• Currently, in ArcGIS 9.3.1:
– Allows you to create, edit and process complex geospatial analysis
models.
– Automate common tasks.
– Document and distribute complex workflows.
• Coming in ArcGIS 10:
– Greater integration with the rest of ArcGIS through an expanded
ArcToolbox.
– More control over logical branching and looping.
Continuing
Education
Python and ModelBuilder
New Integrated Model Window
• ModelBuilder
– Graphic interface
– Elements
• Inputs (blue ellipses)
• Outputs (green ellipses)
• Processes (gold rectangles)
– Drag and drop tools (processes) from ArcToolbox
• Fill in parameter values in dialog boxes
Continuing
Education
Python and ModelBuilder
Input
• Input data can be any of the ArcGIS data types:
–
–
–
–
–
Coverages
Shapefiles
Geodatabase feature classes
Grids
Other ESRI formats
Continuing
Education
Python and ModelBuilder
Input data
Not ready to run
Continuing
Education
Python and ModelBuilder
ModelBuilder Window
• Ready to run
• Model has run
Notice shading
Continuing
Education
Python and ModelBuilder
Tools in Graphics Interface
• Some of the tools on the ModelBuilder toolbar are
there to help you zoom, pan, and organize your
model flow chart
• Two tools are used frequently:
– Arrow tool to select
– Linkage tool to connect inputs, processes, outputs
Continuing
Education
Python and ModelBuilder
Model in ModelBuilder
• A model in this context is a sequence of processes
made up of data and tools.
• The model flow chart gives us a visual representation
of our geoprocessing work flow.
• We can just drag-and-drop our input data sets from
the Table of Contents in ArcMap, and drag-and-drop
our tools from ArcToolbox. We can also drag-anddrop scripts (from Python, etc.)
Continuing
Education
Python and ModelBuilder
Example: ModelBuilder
Continuing
Education
Python and ModelBuilder
Arranging Your Model Elements
• Use the Auto Layout and Full Extent tools to help arrange
your model diagram as you work.
Auto Layout
Continuing
Education
Full Extent
Python and ModelBuilder
Running a Model
• We can choose to:
– Run a single process
– Run all ready-to-run processes
– Run the entire model
• Process boxes temporarily turn red as they execute.
• We receive status messages with each run.
Continuing
Education
Python and ModelBuilder
Editing a Model
• Right-click on a Model in ArcToolbox and go to Edit.
• The ModelBuilder window opens and we can begin editing.
Continuing
Education
Python and ModelBuilder
What is a Parameter?
• In ModelBuilder, our tools often need required or optional
values in order to run. These are parameters.
• For example, the Buffer tool needs a buffer distance in order
to run.
• We can “expose a parameter” to allow user input.
• To do this we will create a parameter as a variable.
Continuing
Education
Python and ModelBuilder
Creating a Parameter Variable
• The first step is to right-click on a tool in your diagram and
select “Make Variable,” then “From Parameter.”
Continuing
Education
Python and ModelBuilder
Creating a Model Parameter
• We now see a new model element, named “Expression.”
Continuing
Education
Python and ModelBuilder
Creating a Model Parameter
• The second step is to right-click on this new model
element and select “Model Parameter.” Now we see
a P label in our model diagram.
Continuing
Education
Python and ModelBuilder
Derived Data
• Data that is output from a
process is called “derived
data.” If output data from a
process is not a final result, it
is “intermediate data.”
• When you right-click on an
intermediate output, you will
see if it has “Intermediate”
checked.
• Intermediate data is
temporary.
Continuing
Education
Python and ModelBuilder
Intermediate Data
• Models run from a dialog box or the command line delete
intermediate data automatically.
• Models run from within ModelBuilder write intermediate
data to disk.
• Your end results will also be flagged as Intermediate by
default – you may need to change this setting.
Continuing
Education
Python and ModelBuilder
Iteration
• You can use the output from a process as an input to another
process.
• You can include iteration by using Lists and Series.
• You can also instruct a model to iterate until a Boolean or
long variable criterion is met.
Continuing
Education
Python and ModelBuilder
Model Validation
• In the Model drop down menu in the ModelBuilder
window, you have the option to “Validate the Entire
Model.” This checks that all of your model
parameters are correct and that your input data can
be found.
• Models that need repair (for example, if an input
data set was moved from its initial location) will
show up in the toolbox with a red X through them.
Continuing
Education
Python and ModelBuilder
Documentation
• ModelBuilder includes documentation functions.
• A good idea with a complex model.
• May become as important as geospatial metadata.
Continuing
Education
Python and ModelBuilder
Element Labels
• You can document each process, data element or connector
with a label.
• These labels stay with their element if the element is moved.
They are deleted if the element is deleted.
• Right-click on an element and select “Create Label.”
Continuing
Education
Python and ModelBuilder
Documentation Editor
• You should document your models for yourself and other
users.
• Start editing your model in the ModelBuilder window. Then
right-click on tool and select “Edit Documentation.”
• The information you write about a tool will be integrated into
the Help file.
• Back in ArcToolbox, you add additional documentation.
Right-click on your model and go to Edit Documentation.
• You can access the documentation through the Help Page, the
metadata tab in ArcCatalog and the model’s side dialog panel.
Continuing
Education
Python and ModelBuilder
Distributing Your Model
• To distribute your model, you will need to set model
Properties. These include:
– Model name, description, etc. (Note that the model name
can not contain any spaces or special characters.)
– Relative paths to the toolbox location (pathnames
maintained relative to the toolbox)
– Preview model parameters
– Preview model environment settings
Continuing
Education
Python and ModelBuilder
Distributing Your Model
•
•
•
•
Save your model as a tool in the Toolbox.
Save your model as a .tbx file (stand alone).
Save your model in a geodatabase.
Make sure your toolbox is read/write to your users,
and that related data, scripts, documentation, etc.
are shared. And that you set relative paths, so that
moving the data doesn’t break the model.
Continuing
Education
Python and ModelBuilder
Export Your Model
• You can export your model as a graphic –
– .bmp, .jpg, .emf
• You can export your model to a script.
• Both are from right-click on the Model in
ArcToolbox.
Continuing
Education
Download