TransWikia.com

How do I get Table from Vector layers for use with joinattributestable

Geographic Information Systems Asked by IceDreamer on September 26, 2021

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?

One Answer

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

Answered by artwork21 on September 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP