0

I need to make a LEFT JOIN (using a Python QGIS script) between two layers:

  • a shape (point): s_node
  • a csv (table): t_infos

Can you show me how to do that?

The result (the joined layers) has to be in a separated/new/virtual layer.

enter image description here

My QGIS version: 3.12.3-Bucuresti

Timeless.
  • 644
  • 4
  • 13
  • 1
    What have you tried so far? Why don't the existing solutions on this site (just look at the "Related" section on the right) work for you? – bugmenot123 Dec 05 '21 at 10:28
  • I wanted to make a try myself but I don't know how to affect my two layers to two variables in the Python Console. Can you show me please how ? I know that for example the function iface.activeLayer() do something like that but only for the active layer I guess.. – Timeless. Dec 05 '21 at 10:31
  • To add a layer as variable you can use layer = QgsProject.instance().mapLayersByName("layer_name")[0] if your layer is already in the project. layer = iface.addVectorLayer("path_to_your_layer", '', 'ogr') if the layer is not in the project. Then you can use one of the script by German Carillo in this post : https://gis.stackexchange.com/questions/133573/joining-table-field-with-shapefile-using-pyqgis?rq=1 – JULESG Dec 06 '21 at 07:44
  • thank you so much @JULESG, it worked 100% ! – Timeless. Dec 06 '21 at 09:26
  • 2

0 Answers0