Add table attributes with joining two files in QGIS

Want to add more attributes in your Shapefile to respective feature? QGIS an open source tool, which I recommend to every Geographer for use, can give you direct solution. Sometimes we need to join more attribute to a GIS vector files which ultimately provide more power to you for analysis with more attributes. For joining two file to add more attribute you need to have a common attribute field in both the files, same as like you need to have primary and foreign key to join two table data in SQL. QGIS provide us the facility to Add more table attributes with joining two files .

You may also be interested to see how to perform Spatial Join in QGIS and other tutorial in QGIS.

 

Add table attributes with joining two files

Steps to Add table attributes with joining two files in QGIS:

We are performing this steps with Shapefile and csv file, while you can also perform the same steps with other GIS vector file and csv file.

1.) Open QGIS and add a shapefile and observe its attribute table.

Add table attributes with joining two files

Here we have two columns.

Add table attributes with joining two files2.) Now We have a comma separated file(.csv) which has to be added. Having two columns i.e osm_way_id and amenity as shown below.

Add table attributes with joining two files
Add table attributes with joining two files

Note : Both the field will store in String format as we have not defined the field type. To define field type, create a new file with the same name of that of csv file but with csvt format in the same folder. For above instance the content should be written as :

“Integer”,”String”

in the file. We can see that osm_way_id is the column which is common in attribute table of shapefile and .csv file. So we can join this two using the same.

3.) First we have to import this file in QGIS. QGIS provide us the facility of importing files which do not have any geographic information also. While importing .csv file we have to take care that default type for .csv file is string if .csvt file is not present in the folder.

QGIS will look for .csvt file for data type in the same folder of same name. If not found all the data would be imported as default type i.e String. Now here all the columns are string so we are not creating a .csvt file.

4.) Lets import this file in QGIS. Click layer than Add Layer and select Add Delimited Text Layer.

Add table attributes with joining two files5.) Select csv radio button and then select no geometry radio button.

Add table attributes with joining two files
Add table attributes with joining two files

6.) Click ok. The file is imported.

Add table attributes with joining two files7.) Let’s join both tables. Open properties dialog box of the layer for which we want to perform join.

Add table attributes with joining two files8.) Click on join.

Add table attributes with joining two files9.) Click on plus sign.

Add table attributes with joining two files10.) Set the dialog box as in the image. We have chosen the field according to which we want to join and the field which we want to join with the table. By default all the fields are added.

Add table attributes with joining two files
Add table attributes with joining two files

11.) Click ok.

Add table attributes with joining two files12.) Click ok for properties dialog box.

13.) The tables are joined. Open the attribute table for the layer for which you performed join. The column name Book1_amenity shows that it was imported from Book1.

Add table attributes with joining two files
Add table attributes with joining two files

Comment below if you are facing any problem in adding attributes data to respective features in QGIs with Join function.

QGIS 3.2.1 User Interface