Model Builder: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
mNo edit summary
Line 1: Line 1:
ArcGIS 9.x has a new thing called "Model Builder" that lets you build scripts in the form of flow charts and then execute them.
ESRI ArcGIS 9 has a new tool called the "Model Builder". It lets you build scripts in the form of flow charts and then execute them.
 
The idea is to make programming more accessible for non-programmers.
The idea is to make programming more accessible for non-programmers.


There used to be a joke in programming school back in the olden days. All flow charts can be simplified to this:
All flow charts for procedural programs can be simplified to this:


[[Image:UniversalFlowChart.jpg]]
[[Image:UniversalFlowChart.jpg]]
Well, we're geeks, we thought it was funny. What can I say? At the time this was (relatively) true, but college professors never accepted it on tests. You always had to flesh things out more. At that time, almost all programming was "procedural". Event driven models, MVC, objects, functional programming... all those cool things were in the future.


A procedural program starts at the top (at the left in this case) and flows from one box to the next until it completes. Model Builder is a tool for building procedural programs. Indeed, the diagram above was built with Model Builder. Ellipses represent data such as feature classes and rectangles are processes; either spatial like transformations or data processes like simple calculations.
A procedural program starts at the top (at the left in this case) and flows from one box to the next until it completes. Model Builder is a tool for building procedural programs. Indeed, the diagram above was built with Model Builder. Ellipses represent data such as feature classes and rectangles are processes; either spatial like transformations or data processes like simple calculations.


Another way to think of procedural programs is to think of a really old computer system. It had a card reader, a central processing unit (CPU), and a printer. Input, processing, output. Put a stack of shape objects into "the card reader", the CPU performs some operation on them, and then it pushes them out into the "printer" (an output feature class).
Another way to think of procedural programs is to think of an early computer system. It had a card reader, a central processing unit (CPU), and a printer. Input, processing, output. Put a stack of shape objects into "the card reader", the Geoprocessor CPU performs an operation on them, and then it pushes them out into the "printer" (an output feature class).


With Model Builder, that's really all there is to it. You just build on this model by chaining things together in stages.
With Model Builder, that's really all there is to it. You just build on this model by chaining things together in stages.
Line 23: Line 20:
===Real Programming (with Python)===
===Real Programming (with Python)===


As a programmer, the Model Builder felt like a straightjacket the first time I tried it. As a programming medium, it is exremely limited.  
As a programmer, the Model Builder felt like a straitjacket the first time I tried it. As a programming medium, it is extremely limited.  


But Model Builder has one big advantage for learning to program in the ESRI domain. Once you have a "model" built and working, you can generate the equivalent Python code as output. (Model->Export->To Script->Python). This gives you a starting point for writing your own Python [[Geoprocessing]] scripts for use as components in Model Builder, or as standalone tools.
But Model Builder has one big advantage for learning to program in the ESRI domain. Once you have a "model" built and working, you can generate the equivalent Python code as output. (Model->Export->To Script->Python). This gives you a starting point for writing your own Python [[Geoprocessing]] scripts for use as components in Model Builder, or as standalone tools.
Line 29: Line 26:
The resultant program will perform all the same steps as your "model" version, so all the hooks to the ArcMap/ArcCatalog interfaces are there, and the calls to the various ArcToolbox tools are there in proper order and set up with the right data.
The resultant program will perform all the same steps as your "model" version, so all the hooks to the ArcMap/ArcCatalog interfaces are there, and the calls to the various ArcToolbox tools are there in proper order and set up with the right data.


4/26/2006 To be continued...
== What about Open Source? ==
 
As much as we all love ESRI, I'd like to be able to do more with Model Builder.
 
You are not limited to using only ESRI tools in your Models.
If you can write a Python wrapper around a program you can add it to your ESIR ArcToolbox.
 
But I'd like a 100% Python model builder.
 
I would start with an UML diagrammer like
 
dia
and dia2code http://dia2code.sourceforge.net/
 
pyut http://pyut.sourceforge.net/index.html
 
gaphor http://gaphor.devjavu.com/
 
Then I'd add a toolbox full of open source and ESRI tools.
 
These go on the [[Python]] page
 
http://pythonide.stani.be/ Python IDE
 
http://pyswarm.sourceforge.net/
 
http://plone.org/about/movies

Revision as of 16:17, 20 December 2007

ESRI ArcGIS 9 has a new tool called the "Model Builder". It lets you build scripts in the form of flow charts and then execute them. The idea is to make programming more accessible for non-programmers.

All flow charts for procedural programs can be simplified to this:

A procedural program starts at the top (at the left in this case) and flows from one box to the next until it completes. Model Builder is a tool for building procedural programs. Indeed, the diagram above was built with Model Builder. Ellipses represent data such as feature classes and rectangles are processes; either spatial like transformations or data processes like simple calculations.

Another way to think of procedural programs is to think of an early computer system. It had a card reader, a central processing unit (CPU), and a printer. Input, processing, output. Put a stack of shape objects into "the card reader", the Geoprocessor CPU performs an operation on them, and then it pushes them out into the "printer" (an output feature class).

With Model Builder, that's really all there is to it. You just build on this model by chaining things together in stages.

You can chain many tools together, and you can use "preconditions" as a simple form of decision-making (branching) but you can't use any advanced iterations or branches. (I suspect that more advanced features are coming down the road.)

Still, there is a lot you can do within the existing framework.

Real Programming (with Python)

As a programmer, the Model Builder felt like a straitjacket the first time I tried it. As a programming medium, it is extremely limited.

But Model Builder has one big advantage for learning to program in the ESRI domain. Once you have a "model" built and working, you can generate the equivalent Python code as output. (Model->Export->To Script->Python). This gives you a starting point for writing your own Python Geoprocessing scripts for use as components in Model Builder, or as standalone tools.

The resultant program will perform all the same steps as your "model" version, so all the hooks to the ArcMap/ArcCatalog interfaces are there, and the calls to the various ArcToolbox tools are there in proper order and set up with the right data.

What about Open Source?

As much as we all love ESRI, I'd like to be able to do more with Model Builder.

You are not limited to using only ESRI tools in your Models. If you can write a Python wrapper around a program you can add it to your ESIR ArcToolbox.

But I'd like a 100% Python model builder.

I would start with an UML diagrammer like

dia and dia2code http://dia2code.sourceforge.net/

pyut http://pyut.sourceforge.net/index.html

gaphor http://gaphor.devjavu.com/

Then I'd add a toolbox full of open source and ESRI tools.

These go on the Python page

http://pythonide.stani.be/ Python IDE

http://pyswarm.sourceforge.net/

http://plone.org/about/movies