When to use ModelBuilder over Python scripting and vice versa?
I believe that the user should clearly define their objectives before deciding which set of tools to use. ModelBuilder and Python scripting excel at different tasks. A few thoughts:
- ModelBuilder has no mapping capabilities, whereas arcpy.mapping does.
- Python can be used to optimize workflows, such as with the multiprocessing package or with parallel processing.
- Python allows for nested loops and other handy iterative logic tools. To accomplish a similar result in ModelBuilder, you would have to construct intricate, and complicated, nested models.
Simple text manipulation is very easy with Python and either very difficult or not possible with ModelBuilder.
e.g. to rename a list of file names from, for example "m_2010_naip_2310345_nw.img" to "2310345nw.img" can easily be accomplished with Python using the
os.path
module.
On the other hand:
ModelBuilder is very useful for quickly putting together common tools and eliminating the need for debugging scripts.
ModelBuilder has a very useful recursive iterator that is easy to implement in order to loop through folders and subfolders.
ModelBuilder excels at visually and intuitively depicting the workflow for complicated tasks.
ModelBuilder can incorporate Python script tools.
If you are working solely within the confines of ArcGIS, there are a few considerations I would consider when attempting to determine the approach to take.
- What are you trying to accomplish,
- What are your current skill sets,
- Will you be sharing your work with others to use, learn from, or manipulate, and
- Who is your intended audience.
Given those considerations:
- It is often quicker and easier to build a process in ModelBuilder than in Python, unless part of your process cannot be replicated in ModelBuilder.
- If you don't know Python & have not intention to learn it, ModelBuilder is a great option.
- If you don't know Python & want to learn to incorporate it into your skill set, ModelBuilder is a great way to start by creating simple models, then exporting them to Python so you have the skeleton of your final process pre-built for you. This method does come at a cost, as there is a lot of extraneous information & variables that usually get created during the conversion process, but it is still a great way to start learning.
- If you are building tools for personal use, using whichever method you feel most comfortable with is usually the route to go. I personally use both, depending on my needs.
- If you are planning to share your analysis with others, and want to share your model/script with others are part of your process documentation, a model is generally much easier to follow and understand for non-technical people.
There probably is no answer to "which is better" for personal use, but if you are looking long-term at employment possibilities, by learning Python you will set yourself apart from those who only know how to use the pre-programmed tools, or just know how to use ModelBuilder. You also give yourself the ability to go outside the confines of Python for ArcGIS (ArcPy), and start automating far more tasks and projects by using other proprietary and open-source GIS libraries, as well as many non-GIS libraries (ie- database, image manipulation, statistics, etc).
Model Builder is a great and easy to learn visual programming language and a good entrance to GIS-programming in general. But in some things python can do more.
One example is the integration of non-ESRI GIS libraries. Nearly all of the Open Source GIS can be adressed via python as well (e.g. GRASS, Sextante, QGIS, SAGA). This helped me a lot, because I only have an ArcView license. So every time I cannot use a certain geoprocessing tool in ArcGIS, I look what other options are available in Open Source GIS. I then take these OpenSource-tools and combine them with ArcGIS tools either in a bigger python script or integrate them in ModelBuilder via a smaller python script.
I´m sure other members can name more advantages.