As per https://docs.qgis.org/3.22/en/docs/user_manual/processing/standalone.html?highlight=qgis_process I am trying to run the following (that works in the QGIS python console).

alg_params = {
           'EXPRESSION': '"Speed KmH"  < '+ str(max_speed) ,
            'INPUT': in_file,
            'OUTPUT': 'd:/scratch/1.tab',

outputs['ExtractByExpression']=processing.run('native:extractbyexpression', alg_params)  

When I run the following in OSGEO Shell I get

C:\OSGeo4W\apps\qgis\bin>qgis_process run qgis:extractbyexpression -- INPUT=d:\scratch\1.csv OUTPUT=D:\scratch\1.tab EXPRESSION="FID"<30                                                                                                                                  

C:\OSGeo4W\apps\qgis\bin>qgis_process run qgis:extractbyexpression -- INPUT=d:\scratch\1.csv OUTPUT=D:\scratch\1.tab Traceback (most recent call last):
Problem with OTB installation: OTB folder is not set.
---------------- Inputs
---------------- INPUT: d:\scratch\1.csv
OUTPUT: D:\scratch\1.tab
ERROR: The following mandatory parameters were not specified
EXPRESSION: Expression

How do I structure the expression? I have tried it in single quotes and double quotes. It accepts the input/output when we use = rather than : but I just can't get even a simple expression to work.


1 Answer 1


You will need to wrap the expression in double quotes, because the < character is a reserved character within the windows command line used for redirecting inputs/outputs.

The following command works for me using QGIS 3.22:

qgis_process-qgis-ltr run qgis:extractbyexpression -- INPUT=D:\Downloads\1.shp OUTPUT=D:\Downloads\1.tab EXPRESSION=""FID"<30"
> ----------------
> Inputs
> ----------------

> INPUT:  D:\Downloads\1.shp
> OUTPUT: D:\Downloads\1.tab
> Warning 6: driver MapInfo File does not support creation option BLOCK_SIZE
> 0...10..
> ----------------
> Results
> ----------------
> OUTPUT: D:\Downloads\1.tab

Some additional notes:

  • my command uses qgis_process-qgis-ltr because I ran on the standalone version of QGIS. With your installation through OSGeo keep using qgis_process
  • if the file paths of input or output contain any spaces (or reserved characters such as & , | , ( , ) , < , > , ^), you also need to wrap the path with double quotes e.g. INPUT="D:\Test Data\1.shp"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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