Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to Python scripting in ArcGIS but not new to ModelBuilder.

I would like to know the benefits of Python vs ModelBuilder.

When should we write Python script for GIS automation rather than use ModelBuilder?

What are the automation capabilities of Python that we cannot find in ModelBuilder?

share|improve this question

6 Answers 6

up vote 56 down vote accepted

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:

  1. ModelBuilder has no mapping capabilities, whereas arcpy.mapping does.
  2. Python can be used to optimize workflows, such as with the multiprocessing package or with parallel processing.
  3. 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.
  4. 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:

  1. ModelBuilder is very useful for quickly putting together common tools and eliminating the need for debugging scripts.

  2. ModelBuilder has a very useful recursive iterator that is easy to implement in order to loop through folders and subfolders.

  3. ModelBuilder excels at visually and intuitively depicting the workflow for complicated tasks.

  4. ModelBuilder can incorporate Python script tools.

share|improve this answer
5  
Described differences between Python and Model Builder in ArcGIS clearly. Thanks –  wetland Apr 7 '13 at 17:34
16  
I would add also: 1. you can run your Python script outside ArcMap 2. You can use ArcObjects in Python, 3. There may be some speed differences. –  Tomek Apr 7 '13 at 19:19
3  
3  
+1 NESTED LOOPS & arcpy.mapping! I like the ability to make calculations within a script and add them to attribute tables or better yet to the map layout (area of each wetland type for example). –  Roy Apr 9 '13 at 19:43
2  
I read python scripting for ArcGIS book . I also add some more capabilities : 1- script cursors let you loop through records in a table, reading the existing rows and inserting new rows. 2- scripting can be used to wrap other software- that is, to glue together application. for example python can be used to access functions in Microsoft Excel or in the statistical Package R. 3-A script can be run as a stand-alone script on disk outside of ArcGIS.you do not need to run ArcMap or ArcCatalog for script to work. (Python Scripting for ArcGIS , Chapter 2 , Page 39) –  wetland Apr 13 '13 at 15:02

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:

  1. 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.
  2. If you don't know Python & have not intention to learn it, ModelBuilder is a great option.
  3. 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.
  4. 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.
  5. 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).

share|improve this answer
    
great. I'll use your Python programming experiences . –  wetland Apr 8 '13 at 5:23

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.

share|improve this answer
    
Thanks but i only use ArcGIS Desktop (ArcInfo) –  wetland Apr 7 '13 at 17:25

When using Python and ArcGIS, you get the entire functionality of Python in addition to what you already had in ArcGIS. If you need this kind of power and flexibility depends on your wishes. In addition, getting to know and really leverage a programming language such as Python takes time. If this investment is worth it for you is up to you. However, for serious data processing a real scripting language is a very good addition in your arsenal.

Apart form any functionality that the ModelBuilder might miss, there is also a more fundamental discussion. In general, scripts are much more suitable to create complex workflows. The code is processed from top to bottom, and complex tasks can be subdivided into smaller sub tasks using e.g. functions. or objects. A graphical tool such as the model builder tends to become a big spaghetti.

share|improve this answer

I'm partial to creating Python scripts. It's more fun to write code than to mess around with connecting lines to boxes and such, for me at least.

What's really great about Python scripting is you can schedule your scripts to run at a time that is convenient for you. If you have a script that takes a while to complete, or needs to be run outside of regular business hours, this is really convenient. You can see an example of how to schedule a script here.

And as @Aaron mentions, you can easily set up looping in a Python script.

If you're just setting out with Python scripting, you might want to create a model with Model Builder and export it as a Python script. I do this sometimes if I'm having trouble understanding how to use several tools in a script. It could help you get a sense for how to put scripts together.

share|improve this answer
    
your answer was very interesting for me.Thanks –  wetland Apr 7 '13 at 18:35

I have found that I seem to get stuck with no solution more with model builder than with python scripting. The somewhat 'black box' nature of model builder to me makes it harder to find where the problem is located.

I have also found that I can find a lot more help on python. I tend to find lots of dead end threads and topics about model builder. There area also fewer example to go by, where as with python, you probably can find small snipets of most parts of any script you are writing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.