Automating Workflows with ModelBuilder and QGIS Processing

Automating Workflows with ModelBuilder and QGIS Processing

Early in my career I inherited a monthly task that everyone dreaded. Every month, a regional agency sent us new land parcel data, and someone had to run it through the same fourteen steps: check the projection, repair the geometry, clip it to the region, intersect it with the zoning layer, calculate areas, dissolve by owner type, join the statistics, export three tables. It took most of a day, and it was done a little differently each time, depending on who did it and how much coffee they’d had. Errors crept in. Once, a whole month’s output was produced with a forgotten filter switched on, and nobody noticed for six weeks.

The fix was not a clever new algorithm. It was writing the workflow down once, in a form the computer could run. In ArcGIS that form is ModelBuilder. In QGIS it is the Graphical Modeler, together with the Processing framework and its command-line and Python interfaces. These visual tools sit in a sweet spot: far more powerful than clicking, far easier than programming. In this guide I’ll explain how they work, how to build your first model in each application, how to design models that last, how to run them in batches and on schedules, and when it’s time to graduate to code.

For the code-based route, see Python for GIS: Getting Started. For the bigger picture, see Geospatial Development & Automation: The Ultimate Guide.

Diagram: A model chains tools so the same steps can run on new input every time.
A model chains tools so the same steps can run on new input every time.

Why Automate a Workflow?

  • Consistency. The same steps, in the same order, every time.
  • Speed. A day of clicking becomes minutes.
  • Fewer mistakes. No forgotten filter, no skipped step.
  • Documentation. The model is the documentation: a diagram of what you did.
  • Reusability. Run the same model on new data, new areas or new dates.
  • Sharing. Colleagues can run your model without knowing how you built it.
  • Scalability. Batch the model across hundreds of inputs.
  • A path into programming. Models can be exported to Python code, so they double as a learning tool.

The best candidates for automation are tasks that are repeated, multi-step and rule-based, and where mistakes are costly.


Core Idea: Inputs, Tools, Outputs

Every geoprocessing workflow, however complicated, is a flow of data.

  • Inputs: layers, tables, rasters, numbers and text that you provide.
  • Tools (algorithms): operations such as Buffer, Clip, Intersect and Join.
  • Outputs: the results, which may become the input of the next tool.
  • Parameters: the settings you may want to change between runs, such as a buffer distance or an output folder.

A model connects them in a diagram. You see the whole logic at once, and you can run all steps with one click. The same logic underlies the techniques in Spatial Analysis in GIS: Complete Guide and Buffer, Clip, Intersect, Union: Overlay Tools Explained.


Part One: ModelBuilder in ArcGIS Pro

The elements of a model

In ModelBuilder, a model is a diagram made of colored shapes.

  • Input data variables (blue ovals): the layers and values you start with.
  • Tools (yellow rectangles): the geoprocessing tools.
  • Derived data (green ovals): the outputs created by tools, which feed the next step.
  • Connectors (arrows): the flow of data.
  • Parameters: inputs or outputs marked as parameters appear in the model’s dialog box when someone runs it.
  • Iterators: elements that repeat part of the model over a set of items.
  • Variables and in-line substitution: values that can be inserted into names and paths.
  • Labels and notes: text that documents the model.

Building your first model

  1. Create a model: on the Analysis tab, choose ModelBuilder. A new, empty model opens inside a toolbox.
  2. Add the input data: drag a layer from the Contents pane into the model.
  3. Add tools: drag tools from the Geoprocessing pane, or use the Tools menu, onto the canvas.
  4. Connect: use the connectors to link the input to the tool, and set each tool’s parameters by double-clicking it.
  5. Chain: use the output of one tool as the input of the next.
  6. Name the outputs clearly, and decide where they go.
  7. Mark parameters: right-click an input or output and choose Parameter to expose it to the user.
  8. Validate and run: validate the model to check the logic, then run it.
  9. Save it in a toolbox, and give it a name and a description.

Iterators: running a step many times

Iterators loop over a set of items, such as every feature in a layer, every file in a folder or every raster in a workspace. Common ones include Iterate Feature Selection, Iterate Rasters, Iterate Files and Iterate Field Values. Combined with in-line variable substitution, you can create one output per iteration, such as clip_%Name%, where %Name% is replaced by the value of each iteration.

Iterators are the key to batch-processing, such as “run this analysis for each municipality.”

Model-only tools and sharing

  • Model-only tools such as Calculate Value, Select Data, Get Field Value and Parse Path let you handle values and logic inside the model.
  • Preconditions and if-then logic control the order and conditions of steps.
  • Sharing: models live in toolboxes, which can be shared, and published as geoprocessing services on ArcGIS Enterprise.
  • Export to Python: a model can be exported as a script, which is an excellent way to learn ArcPy and to move beyond the model’s limitations.

Environment settings

Geoprocessing environment settings govern how tools behave: the processing extent, cell size, output coordinate system, scratch workspace and whether to overwrite outputs. Setting them deliberately inside a model avoids many surprises. For example, a model that overwrites its outputs can be rerun without errors, and a fixed output coordinate system prevents mismatches.


Part Two: The Graphical Modeler in QGIS

The Processing framework

QGIS has a unified collection of analysis tools called the Processing framework, found in the Processing Toolbox (Processing > Toolbox). It brings together native QGIS algorithms and those from GDAL, GRASS, SAGA and other providers, all with the same style of dialog. Because every tool follows the same pattern, they can be chained, batched and scripted in a uniform way. See Best Free and Open-Source GIS Tools for the ecosystem and Best GIS Plugins for QGIS for plugins that add Processing algorithms.

The Graphical Modeler

Open it from Processing > Graphical Modeler. The window has two panels: Inputs on one side, and Algorithms on the other, and a canvas in the middle.

Building your first model

  1. Create a model and give it a name and a group.
  2. Add inputs from the Inputs panel, such as a Vector layer, a Number (for a distance), a CRS, an Extent or a String. Each input becomes a field in the model’s dialog.
  3. Add algorithms from the Algorithms panel, for example Reproject layer, Fix geometries, Clip and Buffer.
  4. Connect them: in each algorithm’s dialog, choose where each parameter comes from: a model input, the output of another algorithm, or a fixed value.
  5. Define the outputs: mark which results should be saved as final outputs, and which are temporary.
  6. Describe the model with a help text for the dialog.
  7. Run it from the modeler, or save it and run it from the Processing Toolbox like any other tool.
  8. Save it as a .model3 file, which you can share and reload.

A good first model is “Clean and clip a layer”: it takes a vector layer, a study area and a CRS, fixes invalid geometries, reprojects, clips and writes a GeoPackage. It captures three of the most common chores in a single reusable tool.

Useful features

  • Run as Batch Process: right-click any Processing algorithm, or your model, and choose Execute as Batch Process to run it on many inputs, with a table where each row is one run. A simple way to process a whole folder.
  • Processing history: every run is logged, and you can copy a run as a Python command, which is a great way to learn the code behind the dialogs.
  • Edit model help and parameters, so that other users understand the tool.
  • Export as Python script: the modeler can export your model as a Python Processing script.
  • Nested models: a saved model appears in the toolbox, so it can be used inside other models.

Running Processing from Python

Everything in the toolbox can be called from code. In the QGIS Python console:

import processing

result = processing.run("native:buffer", {
    "INPUT": "roads.gpkg|layername=roads",
    "DISTANCE": 100,
    "SEGMENTS": 5,
    "DISSOLVE": True,
    "OUTPUT": "buffers.gpkg"
})
print(result["OUTPUT"])

The algorithm name, native:buffer, and the parameter names, in capitals, are shown in the algorithm’s dialog under Advanced > Copy as Python Command, which is the easiest way to get them right. You can then place such calls in a loop, a function or a script.

Running Processing without the QGIS window

QGIS includes a command-line tool, qgis_process, that runs Processing algorithms, and models, without opening the application. It is ideal for servers and scheduled jobs:

qgis_process list
qgis_process help native:buffer
qgis_process run native:buffer --INPUT=roads.gpkg --DISTANCE=100 --OUTPUT=buffers.gpkg

Check qgis_process help for the exact syntax in your version. Combined with a scheduler (below), it allows fully automatic pipelines.

Writing your own Processing script

When no existing algorithm does what you need, you can write a Python Processing script, which then appears in the toolbox with its own dialog. QGIS offers a script editor and templates, and a simple decorator-based style for defining inputs and outputs. This is a halfway house between a visual model and a full plugin, described in Best GIS Plugins for QGIS and Geospatial Development & Automation: The Ultimate Guide.


ModelBuilder vs. QGIS Modeler vs. Scripts

AspectModelBuilder (ArcGIS Pro)Graphical Modeler (QGIS)Python scripts
InterfaceVisual canvasVisual canvasText code
Learning curveGentleGentleModerate
CostPart of ArcGISFreeFree
Looping and batchIteratorsBatch process, limited loops in a modelFull control
Complex logicLimited, with model-only toolsLimitedUnlimited
Version controlAwkward (binary models)Moderate (text-based model file)Excellent (plain text, Git)
SharingToolboxes, services.model3 filesFiles, packages
SchedulingVia script export or servicesqgis_processScripts and any scheduler
Best forRepeatable Esri workflowsRepeatable open-source workflowsComplex, large or data-science workflows

A sensible path: start visual, then move to code when a workflow needs complex logic, loops, error handling, integration with other systems or version control. Exporting a model to Python gives you the starting point.


Designing Models That Last

A model that only its author understands is a liability. These principles keep models useful.

1. One clear purpose

A model should do one job well, such as “prepare parcels for analysis.” Large workflows are better built from several small models, called in sequence.

2. Parameterize everything that changes

Distances, thresholds, input layers, output folders and the CRS should be parameters, not buried in tool dialogs. Avoid hardcoded paths, such as C:\Users\me\data\parcels.shp, which break on any other computer.

3. Name things clearly

Give inputs, tools and outputs meaningful names, such as “flood_zone_clipped” rather than “Output 3”. Use labels and descriptions, so that the diagram explains itself.

4. Use temporary outputs for intermediate steps

Save only the final results. Intermediate layers can live in memory or a scratch workspace, which keeps your project clean and runs faster.

5. Validate inputs

Add checks where possible: a CRS is defined, geometries are valid, required fields exist. A model that fails early with a clear message is better than one that runs for an hour and produces nonsense.

6. Handle the CRS deliberately

Mismatched coordinate systems are the number one cause of silent errors in models. Reproject all inputs to a single, suitable projected CRS at the start, and state it. See Coordinate Reference Systems (CRS) Explained Simply and Map Projections: How to Choose the Right One.

7. Repair geometry early

Include a Fix geometries or Repair geometry step after importing data, because invalid shapes break overlays. See Top 10 Most Common GIS Errors and How to Fix Them.

8. Make outputs predictable

Write results to a defined folder with consistent names, and include the date or the input name where useful.

9. Test on small data first

Run on a small area or a few features. When it works, run on the full dataset.

10. Document and version

Describe the purpose, inputs, outputs, assumptions and the author in the model’s help. Keep a changelog, and store models in a shared location, ideally under version control. Document the data that goes in and out, as in Metadata in GIS: Why It Matters and How to Create It.


A Worked Example: Flood Risk Summary by Municipality

Goal: a reusable tool that takes buildings, a flood zone and municipality boundaries, and produces a table of buildings at risk per municipality.

StepArcGIS Pro (ModelBuilder)QGIS (Graphical Modeler)
1. InputsBuildings, Flood zone, Municipalities, Output workspace as parametersSame inputs as Vector layer parameters, plus a CRS
2. HarmonizeProject each layer to a common CRSReproject layer, for each input
3. RepairRepair GeometryFix geometries
4. Find exposed buildingsSelect Layer By Location, then Copy FeaturesExtract by location
5. Assign municipalitySpatial JoinJoin attributes by location
6. SummarizeSummary Statistics (count, sum of area) by municipalityStatistics by categories, or Aggregate
7. OutputTable to the output workspaceOutput saved as a table or a GeoPackage

Run it once to test, then reuse. When the flood map is updated next year, the municipality gets its new table in a minute, using exactly the same method. See GIS in Disaster Management and Emergency Response for the context.

Going further with iteration

To produce one report per municipality, wrap the summary steps in an iterator, such as Iterate Feature Selection in ModelBuilder, and write outputs with the municipality name in the file name. In QGIS, use the Batch option, or the Split vector layer algorithm followed by a batch run, or loop in Python with processing.run.


Running Models in Batches and on a Schedule

Batch processing

  • ArcGIS Pro: use iterators inside a model, or the Batch option on a tool, to run it on many inputs.
  • QGIS: right-click an algorithm or model and choose Execute as Batch Process, then add one row per input, or auto-fill from a folder of files.
  • Python: loop over files and call the model, or processing.run.

Scheduling

For tasks that must run every night, week or month:

  • ArcGIS Pro: export the model to a Python script, then run it with the Windows Task Scheduler or an equivalent on other systems, using the Python environment that ships with ArcGIS Pro. On enterprise systems, publish the model as a geoprocessing service.
  • QGIS: call qgis_process, or a Python script, from the Windows Task Scheduler, cron on Linux and macOS, or a workflow tool.
  • Logging: write a log file for each run, with start and end times, the inputs and any errors. When a job fails at 3 a.m., the log is the first place you will look.
  • Notifications: send an email or message when a run fails.
  • Monitoring: check that the scheduled job really ran, not only that it was configured.

A scheduled pipeline can pull new data, process it, update a database, and refresh a dashboard, without anyone touching it. See Story Maps and Interactive Dashboards.


Troubleshooting Models

  • “The model runs, but the result is empty.” Often a CRS mismatch, or a filter that selects nothing. Check each intermediate output.
  • “Error: invalid geometry.” Add a repair step before overlays.
  • “Output already exists.” Enable overwriting, or write to unique names.
  • “A tool can’t find its input.” Paths are hardcoded, or a layer name changed. Use parameters.
  • “The model is slow.” Clip inputs early, avoid unnecessary intermediate files, use spatial indexes and simplify where appropriate. For huge data, move to a spatial database. See PostGIS: A Practical Introduction.
  • “It works on my computer but not on a colleague’s.” Differences in software versions, installed plugins, extensions, licenses or folder paths. Document dependencies, and keep paths relative or parameterized.
  • “An algorithm changed after an update.” Parameters and names evolve. Test models after upgrading, and pin the software version for production.
  • “The iterator ran, but all outputs have the same name.” The output name does not include the iteration variable.
  • “A required extension or license is missing” (ArcGIS). Check that the license for the tools you use is available.
  • Read the messages. Both applications report errors and warnings in detail. Read them from the start of the run, not only the last line.

Common Mistakes

  • Building a giant, tangled model that nobody can follow. Break it into smaller models.
  • Hardcoding paths and values.
  • No documentation, so the model becomes a black box.
  • Ignoring the CRS, and mixing systems silently.
  • Saving every intermediate result, cluttering folders.
  • Not testing with edge cases, such as empty inputs, null values and multipart geometries.
  • Forgetting about data updates: a model that assumes a fixed layout will break when the source changes.
  • Overwriting source data. Always write to new outputs.
  • Relying on a single person’s knowledge, with no backup or documentation.
  • Staying visual too long. When a model needs loops, branching and complex error handling, switch to code.
  • Never reviewing the results of an automated process. Automation makes mistakes scalable, so build checks into it.

When to Move to Python

Visual tools are wonderful until they aren’t. Consider code when:

  • You need complex conditions or loops that tangle the diagram.
  • You want version control and code review.
  • You need error handling, logging and notifications.
  • You integrate with databases, web services and other systems.
  • You process very large data that needs chunking or a database.
  • You want to test your workflow automatically.
  • You need to run without a desktop GIS, for example on a server.

The transition is smooth. Export your model, read the Python, and modify it. See GeoPandas and Shapely: Vector Data in Python and Raster Processing in Python: Rasterio, Xarray, and NDVI from Code for the open-source libraries, and Spatial SQL Cheat Sheet for pushing heavy work into the database.


Final Thoughts

Automating a workflow is a small act of generosity toward your future self and your colleagues. The model you build today is the day you save next month, the error you never make and the documentation you never have to write. It doesn’t need to be clever. It needs to be clear, parameterized and tested.

Choose a task that you did at least three times last month. Draw it as a model, in whichever application you use. Run it. Then ask a colleague to run it on their own data without help. If they succeed, you have built something real.

Where to go next: try the code route with Python for GIS: Getting Started, and learn to move your data work into a database with Spatial SQL Cheat Sheet.

Rachid Khouri

Rachid Khouri

Rachid Khouri is a CAD, BIM and GIS professional, Autodesk Authorized Developer, trainer and technical author with more than 30 years of experience, working with AutoCAD since 1992. He founded GISauthority.com to share practical guidance on GIS and spatial technologies.