I am attempting to run:

processing.runandload('qgis:joinattributestable', layer1, layer2, 'id', 'id', None)

To join my tables and output to a temporary viewing layer.

layer1 and layer2 are both Spatialite imports. They are vector type objects within QGIS.

joinattributestable specifies the following inputs:

ALGORITHM: Join attributes table
    INPUT_LAYER <ParameterVector>
    INPUT_LAYER_2 <ParameterTable>
    TABLE_FIELD <parameters from INPUT_LAYER>
    TABLE_FIELD_2 <parameters from INPUT_LAYER_2>
    OUTPUT_LAYER <OutputVector>

How can I get ParameterTable from my Vector object?


To convert layer object to table try this:

myCSV = 'C:/Temp/myCSV.csv' # change path or .csv file name if needed
QgsVectorFileWriter.writeAsVectorFormat(layer2, myCSV, "utf-8", None, "CSV")
result = processing.runandload('qgis:joinattributestable', layer1, myCSV, 'id', 'id', None)
memoryLayer = processing.getObject(result['OUTPUT']) # this create the object layer
| improve this answer | |
  • Perhaps I wasn't clear. I cannot run the algorithm because layer2 as third argument is invalid. It's a vector. Not a table. I need to turn it into a table. – IceDreamer Aug 25 '17 at 13:14
  • Updated my answer – artwork21 Aug 25 '17 at 16:41

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.