I am trying to make a QGIS plugin, and one of my goals is to use the geoprocessing tool "intersection" of QGIS into my Python code for the plugin. When I run it directly into QGIS, it works perfectly (especially transferring all attributes of both layers intersected).
When I run it in Python code, the result is the same but the attribute table does not contain all attributes (only one attribute...).
Here is an extract of my code for this purpose:
processing.runandload("qgis:lineintersections", final_layer1, final_layer2, "", "", output_intersect_path)
I also tested:
processing.runalg("qgis:lineintersections", final_layer1, final_layer2, "", "", output_intersect_path) intersect_temp = QgsVectorLayer(output_intersect_path, output_intersect, "ogr") QgsMapLayerRegistry.instance().addMapLayer(intersect_temp)
The problem lies in the parameters: final_layer1 and final_layer2 or the layers intersected. Then, the source help says "Field A" and "Field B", but I do not know what to put for those parameters in order to get all attributes transfered...
Does someone know how to do that ?
Here is my code:
layer1_field = "last_fieldName" layer2_field = "last_fieldName" ouput_0 = processing.runalg("qgis:lineintersections", final_layer1, final_layer2, None, None, None) output_1 = processing.runalg("qgis:joinattributestable", ouput_0['OUTPUT'], final_layer1, layer1_field, layer1_field, None) result = processing.runandload("qgis:joinattributestable", output_1['OUTPUT_LAYER'], final_layer2, layer2_field, layer2_field, None)
Don`t know why it is not good at all....
Here are the source shapefiles to test.