1

I'm trying to make a selection by attribute with python on QGIS Essen, but it looks like I am making a mistake on the script and I can not find it. Can somebody tell me what I have made wrong, or how can I select attributes without using the select by attribute algorithm?

This is my script:

pas14=processing.runalg('qgis:selectbyattribute',r'C:\Users\s.galan\Desktop\TFM_SORAYA\03_Model\Capes_script\polygonize1.shp','valor',0,3,r'C:\Users\s.galan\Desktop\TFM_SORAYA\03_Model\Capes_script\select1')
select1=QgsVectorLayer(r'C:\Users\s.galan\Desktop\TFM_SORAYA\03_Model\Capes_script\select1.shp','select1','ogr')
QgsMapLayerRegistry.instance().addMapLayer(select1)

And this is the error:

Error: Wrong number of parameters

ALGORITHM: Select by attribute

    INPUT <ParameterVector>
    FIELD <parameters from INPUT>
    OPERATOR <ParameterSelection>
    VALUE <ParameterString>
    OUTPUT <OutputVector>

OPERATOR(Operator)

    0 - =
    1 - !=
    2 - >
    3 - >=
    4 - <
    5 - <=
    6 - begins with 
    7 - contains
1

I think the confusion lies with the OUTPUT parameter where the algorithm does not require this as you're only selecting attributes from the same layer. Remove this from your algorithm (this should also be removed from the documentation in my opinion).

So your algorithm should look like:

pas14=processing.runalg('qgis:selectbyattribute',r'C:\Users\s.galan\Desktop\TFM_SORAYA\03_Model\Capes_script\polygonize1.shp','valor',0,3)
1

Actually ignore this - I misinterpreted the question.

  • What was the bug you mentioned? Was it related to "Unsupported field type "Integer64"? – Joseph Apr 28 '16 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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