Here's How to Run QGIS Processing Algorithms from the Command Line

17 Jul 2020 ᛫ 3 min read


QGIS 3.14 (Pi) introduced the qgis_process tool – a command-line executable that “allows users to run processing algorithms (both built-in, and those provided by plugins) directly from the console” developed by Nyall Dawson and sponsored by the Swedish User Group. You can find the Pull Request of the feature here.

Being run straight from the console and outside the QGIS GUI application, qgis_process provides users the ability to harness the full power of the QGIS processing algorithms through batch files, shell scripts, and other operating system tools. This is also useful if you want to use QGIS processing algorithms externally without needing to write Python (or PyQGIS) scripts.

Currently, the tool has several commands:

qgis_process run native:centroids --INPUT="my_shapefile.shp" --OUTPUT="centroids.kml"
qgis_process run native:buffer --INPUT=/home/me/my.shp --DISTANCE=20 --OUTPUT=/home/me/buffered.shp

Running the qgis_process tool

If you are on Linux, the tool can be accessed directly from the terminal. For Windows users, you can access the tool from the OSGeo4W shell (this usually comes installed with QGIS).

In my examples, I run this tool on a machine with a Pop! OS 20.04 (based on Ubuntu 20.04) operating system.

qgis_process list

If you want to find what algorithms you can run, enter qgis_process list on the terminal.

qgis_process list
Running qgis_process list

qgis_process help algid

If you want help for a specific algorithm (e.g. you want to know its parameters/arguments), enter qgis_process help algid on the terminal. algid refers to the id used by QGIS to identify the algorithm. Veterans and power users of the QGIS processing framework are probably already familiar with this. For beginners, these are the first items per line of the qgis_process list output and follows the format : (e.g. native:dissolve which refers to the dissolve algorithm provided by QGIS natively).

qgis_process help native:dissolve
Running qgis_process help

Take note of the Arguments listed by qgis_process help. These are the arguments/parameters that can be provided when running the algorithm. Some arguments/parameters are optional. To learn more about QGIS processing algorithms and their parameters, you can check the QGIS documentation or this list made by Thomas Gratier.


INPUT: Input layer
	Argument type:	source
	Acceptable values:
		- Path to a vector layer
FIELD: Dissolve field(s)
	Argument type:	field
	Acceptable values:
		- The name of an existing field
		- ; delimited list of existing field names
OUTPUT: Dissolved
	Argument type:	sink
	Acceptable values:
		- Path for new vector layer

For native: dissolve, we have INPUT, FIELD, and OUTPUT. Adding these arguments/parameters to the command is done via a --param=value syntax.

qgis_process run

Let’s run a simple dissolve algorithm. First, add/export the QT_QPA_PLATFORM variable (for Linux).

export QT_QPA_PLATFORM='offscreen'

Afterwards, run the algorithm.

qgis_process run native:dissolve --FIELD="[]" --INPUT="/path/to/input.vector" --OUTPUT="/path/to/output.vector"

In my example, I used a geojson containing features of municipalities of a province and dissolved them to have a geojson with just the feature of the province.

Running qgis_process run

You can check your output by opening it in QGIS.

Hat-tip to Totò Fiandaca for the original post here.

comments powered by Disqus

You may also like:

Why You Shouldn't Use QGIS

22 Oct 2019 ᛫ 1 min read

Learning Tools on Web GIS: Introduction to Web Maps and Web GIS

10 Oct 2019 ᛫ 1 min read

Geotagged Photos in QGIS

22 Sep 2019 ᛫ 4 min read

Bivariate Choropleth Maps in QGIS

15 Sep 2019 ᛫ 5 min read

#PistaNgMapa: Beyond the Basics with QGIS 3.X

02 Aug 2019 ᛫ 1 min read


[email protected]

Creative Commons License
This work and its contents by Ben Hur S. Pintor is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Other works (software, source code, etc.) referenced in this website are under their own respective licenses.
This site is powered by Jekyll and hosted on Github (view source)