Download presentation
Presentation is loading. Please wait.
Published byDarcy Chandler Modified over 8 years ago
1
Technical Workshops | Esri International User Conference San Diego, California Branching and Iteration in ModelBuilder Shitij Mehta July 24, 2012 3:15 pm - 4:30 pm
2
Questions for you How many User Conferences have you been to? Geoprocessing experience? - Little (rarely used) - Some (know the basics) - Advanced (build your own tools) - Guru (anointed or legendary?) Platform? - 9.3 - 10.0
3
Outline - I apologize - there is a lot to cover Branching – 30 minutes - Calculate Value - Demo 1 - Tool – Feature Type - Demo 2 – Shape Type - Demo 3 – Merge Branch - Demo 4 - Script tool example Iteration – 30 minutes - Demo 1- Iterate Feature Classes - Demo 2 – Iterate For - Demo 3 – Iterate Feature Selection - Demo 4 – Iterate Multivalue - Demo 5 – 2 Level Nested Model - Demo 6- 3 Level Nested Model - Python Equivalent of Iterators in ModelBuilder
4
All presentations will be available online!!!!!!!
5
What is Branching? IF some condition is true, THEN perform an action; ELSE the condition is false, perform a different action. File in Workspace File in Workspace If file X exists Add a field Else if file X does not exists Copy and then add a field Else if file X does not exists Copy and then add a field Feature Class If has X projection Do nothing If has X projection Do nothing Else - Project Examples
6
How to branch? The condition - If-then-else 1 Calculate Value tool 1 Calculate Value tool 2 Script tool 2 Script tool Where to find the tool Python Code Data types Preconditions in a model Inline Variable Substitution Merge Branch tool Creating a script tool Python code Setting script tool properties Preconditions in a model Merge Branch tool OR
7
Inline Variable Substitution The value of any variable can be used in the tool parameters by enclosing the name of the substituting variable between the percent signs (%). Substituting variables in this manner is called inline variable substitution.inline variable substitution
8
Inline variable substitution In SQL expressions - Name = ‘%Value%’ - “%Value%”.replace( “ ”, “”) In Output name – C:\Scratch\Scratch.gdb\%Value% If string put “quotes” around your inline variable substitution
9
Precondition Preconditions can be used to explicitly control the order of operations in a model. Any variable can be made a precondition to tool execution, and any tool can have more than one precondition.
10
Demo 1 Branching using the Calculate Value tool
11
Demo 2 Branching using a Script tool
12
Where to get help? Click Doc, BlogsDoc 1.Understanding which if troubles youUnderstanding which if troubles you 2.If you are stuck at "if" – Part 1 – Branching using the Calculate Value toolIf you are stuck at "if" – Part 1 – Branching using the Calculate Value tool 3.If you are stuck at "if" – Part 2 – Example of using Script tool to create branches using if-else logicIf you are stuck at "if" – Part 2 – Example of using Script tool to create branches using if-else logic 4.If you are stuck at "if" – Part 3 – Does Extension Exists model exampleIf you are stuck at "if" – Part 3 – Does Extension Exists model example 5.If you are stuck at "if" – Part 4 – Does Selection Exists model exampleIf you are stuck at "if" – Part 4 – Does Selection Exists model example 6.If you are stuck at "if" – Part 5- Does Projection Exist model exampleIf you are stuck at "if" – Part 5- Does Projection Exist model example
13
Iteration
14
Iteration = looping = repeat a process over and over Iteration in ModelBuilder = Run entire model or a single tool or a set of tools repeatedly Tools to iterate in ModelBuilder = Iterators Example - Iterate over a list of feature classes and project each feature class. What is iteration? Iterator
15
Iterates over a starting and ending value by a given value. Iterates "while" a condition is true or false. Iterates over features in a feature class. Iterates over rows in a table.Iterates over each value in a field. Iterates over a list of values. Iterates over datasets in a Workspace or Feature Dataset. Iterates over feature classes in a Workspace or Feature Dataset. Iterates over files in a folder. Iterates over rasters in a Workspace or a Raster Catalog. Iterates over tables in a workspace. Iterates over workspaces in a folder. For Value While Continue Iterate Feature Selection Iterate Feature Selection Value Selected Features Selected Features Iterate Row Selection Iterate Row Selection Value Selected Rows Selected Rows Iterate Field Values Iterate Field Values Value Iterate Multivalue Iterate Multivalue Value Iterate Datasets Iterate Datasets Name Dataset Iterate Feature Classes Iterate Feature Classes Name Feature Class Feature Class Iterate Files Iterate Files Name File Iterate Rasters Iterate Rasters Name Raster Iterate Tables Iterate Tables Name Table Name Workspace Iterate Workspaces
16
Accessing the iterators in ModelBuilder
17
Demo 1 Iterating Feature Classes
18
Demo 2 Iterating For
19
Demo 3 Iterating Feature Selection
20
Demo 4 Iterating Multivalue
21
Demo 5 Model within a Model Main Model Sub-Model
22
Demo 6 Model within a Model within a Model 3 Level Nested Models Model 1 Model 3 Model 2
23
Rules for a nested model/model within a model Only one iterator can be used per model. Add only the tools you want to run as many times as an iterator in the same model. The script will not include the iteration logic if a model with an iterator is exported to a Python script. The output of any tool connected to the iterator can have (if required) a unique name for each iteration to avoid being overwritten by Using the system variable %n% C:\Sctatch\scratch.gdb\output_%n% Using the Name or Value output of the iterator C:\Sctatch\scratch.gdb\output_%Name% C:\Sctatch\scratch.gdb\output_%Value% Using any other variable in the model as an inline variable C:\Scratch\scratch.gdb\output_%XYZ%
24
Rules for a nested model/model within a model Give default values to your sub model for setting and testing it Make model parameters in your sub-model that you want as variable in main model
25
Python Equivalent of Iterators in ModelBuilder
26
Where to get help? Click Doc, Tutorials, BookDocTutorialsBook
27
Questions? Please fill out the evaluation form online at: http://www.esri.com/ucsessionsurveys Session ID - 1914
28
24 th July - Tuesday 1:30PM 2:45PM Technical Workshop Analysis and Geoprocessing ModelBuilder - Getting StartedBall06 B 3:15PM 4:30PM Technical Workshop Analysis and Geoprocessing Iteration and Branching in ModelBuilder Ball06 B 25 th July - Wednesday 8:30AM 9:45AM Technical Workshop Analysis and Geoprocessing Geoprocessing with ArcGIS for Server04 8:30AM 9:45AM Technical Workshop Analysis and Geoprocessing Network Analyst—Automating Workflows with Geoprocessing 10 10:15AM 11:30AM Technical Workshop Analysis and Geoprocessing Building Tools with ModelBuilderBall06 D 1:30PM 2:45PM Technical Workshop Analysis and Geoprocessing Building Tools with Python28 E 1:30PM 2:45PM Technical Workshop Analysis and Geoprocessing ModelBuilder - Getting StartedBall06 B 2:00PM 3:00PM Demo Theater Presentation Analysis and Geoprocessing ModelBuilder Tips and Tricks Demo Theater - Analysis and Geoprocessing Exhibit Hall B 26 th July - Thursday 8:30AM 9:45AM Technical Workshop Analysis and Geoprocessing Geoprocessing with ArcGIS for Server09 10:15AM 11:30AM Technical Workshop Analysis and Geoprocessing Building Tools with Python09 1:30PM 2:45PM Moderated Paper Session Analysis and Geoprocessing Building Applications Using ModelBuilder and Python Scripting 27 A 3:15PM 4:30PM Technical Workshop Analysis and Geoprocessing Building Tools with ModelBuilderBall06 D
29
Thank You!!!!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.