QGis Tutorial II: how to join data with shapefiles

In this tutorial I’ll show you, how to combine text information with spatial information using the open source software QGis. You can easily download and install QGis from the following Source: QGIS DOWNLOAD PAGE.


We will join data given by a shapefile with data provided by a csv file.

what do you need

time effort

approx. 5-10 minutes

step 1 – import the shapefile

QGIS has three options to add data to your layer table.

  1. If you are aware of shapefiles and the corresponding file types in an explorer you may simple drag the shp-file to the layer table and that’s it.
  2. The second possible way is to use the interface: Layer >> Add Vector Layer.
  3. The third way is to use the button “Add vector Layer”
    Vector Layer Button in QGIS
    “Add Vector Layer” button in QGIS

Now choose the correct encoding of the attribute values of the shapefile which. Normally you are good in choosing UTF-8.

encoding browsing and choosing dialog for vector layers in qgis
open diaolog for vector layers

Last step is to choose the needed file:
dialog to open vector layers in QGIS
choosing the right file *.shp in the dialog

The result should look like this:
shape of local areas in Germany imported in QGIS
local areas in Germany imported in QGIS

step 2 – adding the text information

Now there is a crucial misunderstanding in definition of adding *.txt or *.csv files. For adding a simple table to a QGIS project you will add it as a “vector layer”. Please don’t ask why…

add csv text table to QGIS project
add the text information to your QGIS project

It will be available in your workspace afterwards. In General you need to make sure that there is an attribute in your shapefile like “ID” that works like a bridge to the other dataprovider. SO you need a corresponding field like “KEY” that has the same value. So you can define “ID” == “KEY” and the connection of one feature of the shapefile to the corresponding entry/line in the *.csv file. In our case this is the field “AGS” in the *.shp file and “ID” in the *.csv file

step 2 – establishing the connection

Establishing a connection is quite easy. Open the layer properties and choose the tab “Joins”. After that press the add-Button and choose the desired table and join-fields:

defining a join in QGIS using a shp file and a csv file
defining a join in QGIS using a table and a shp file

You will now be able to see the attributes of the *.csv file in the attribute table of the *.shp file. Please keep in mind that all the added field are threatened as string values. But in following video you will not only see the described steps above but also how to transform string values to keyfigures / real numbers:

[youtube http://www.youtube.com/watch?v=g4KqFQFSPe8&w=560&h=315]

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments