9

For a certain project I'm required to run QGIS processes on a large data set on a Linux server as my PC does not have the sufficient memory to execute them (snapping points to lines + Steiner tree extraction using national road data).

Is it possible to run QGIS without the aid of its GUI only using the Command Line Interface?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Nandula
  • 783
  • 4
  • 15

3 Answers3

6

Starting with the release of QGIS 3.14 there is a real QGIS command line mode to use processing algorithms It's called qgis_process. See the change log and search for the new feature: New standalone console tool for running processing algorithms.

D Pilon
  • 608
  • 7
  • 8
4

Assuming you want to use PyQGIS python scripts to automate your workflow, you could do something like the following (roughly based on what I do for automated testing of a QGIS 3 python plugin in my Travis CI setup):

export PREFIX=/usr  # for a standard install, I also use PREFIX=$CONDA_PREFIX if I've installed into an activated conda env
export QT_QPA_PLATFORM=offscreen  # Allow QT/QGIS to run headless
export PYTHONPATH=$PREFIX/share/qgis/python/plugins/processing:$PREFIX/share/qgis/python:$PYTHONPATH
python my_qgis_script.py
user2856
  • 65,736
  • 6
  • 115
  • 196
1

So I'm gonna answer again, with an example of using qgis_process because the top answer leads to a page that didn't help me very much. Speaking from having just figured this out yesterday.

In terminal:

First, allow qgis to run headless (assuming you don't have a display hooked up to the linux server)

$ export QT_QPA_PLATFORM=offscreen

Then you can run qgis_process help to see the help page that will tell you how to use the tool:

$ qgis_process --help

Basically, it goes something like this:

$qgis_process run [some qgis tool, a .model3 file, or python script] \
--paremeter=value \
--parameter2=value
MidPiedmont
  • 118
  • 7