Tuesday, 14 August 2018

Joining data from Excel to attribute table in QGIS without creating duplicates?


I have an attribute table with two empty fields in QGIS.


Example_1


I want to import an excel database to fill my empty fields in QGIS. My excel file matches the columns in my QGIS attribute table.



Example_2


I am able to properly join my excel (.CSV) to my shapefile. However,the process, instead of filling the blank fields as I wish, created duplicates. With the help of « Table Manager » I am able to correct the situation, but it requires a lot of time. I am looking for a more efficient way to join my excel data.


Example_3


How can I join my excel file to my attribute table without creating duplicates?



Answer



I would do the following things to make life easier:


Before you do this, make a backup of your shapefile.



  1. In your shapefile, go to the layer properties / fields and turn on edit mode.

  2. select all Field except the ID field


  3. Delete all fields except the ID Field

  4. add your csv file as a layer in QGIS (Main menu/Layer/Add Layer/ Add delimited text layer)enter image description here (choose no geometry)

  5. in your shapefile, select properties/joins and choose both ID fields for source and target. As described in the other answer to this question.

  6. Save your modified Shapefile.


enter image description here


this is the Field tab I am referring to


enter image description here


Don't forget to toggle editing before and after deleting unnecessary field


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...