I would like to add attributes from an spss database (around 300 cases) to a polygon layer in QGIS. Both datasets have a column with unique IDs. I exported the spss data to a CSV file which does not contain x,y values.
The "add delimited text layer" plugin seems to require x and y values. How can I add the CSV data to the polygons?
Answer
You need to Join the attribute table and the CSV. Assuming the Unique IDs are common between the spatial data and the CSV, they will be used as the join field. See this tutorial for great step-by-step instructions.
This is a summary of the points from the tutorial. See the tutorial for more details and screenshots.
- add the spatial data to the view in QGIS
- open the CSV in a text editor
- make sure any column names that are only numbers are enclosed in double quotes (e.g. a column named 2009 should be changed to "2009")
- if any of the data is numeric you will need to create a CSVT file so that QGIS doesn't convert the field to text (if you want to perform math with those numbers)
- examine the attribute table and the CSV to know which column names will be used for the join
- probably the Unique IDs for the data in Martin's question
- add the CSV file to QGIS by clicking (on the menu)
Layer > Add Vector Layer
- the table should appear in the Table of Contents
- make sure the data in the CSV table was imported correctly by right-clicking on it (in the Table of Contents) and choosing
Open Attribute Table
- double-click on the spatial data layer to open Properties
- click the
Joins
tab - click the
+
icon to create a new join- Join Layer is the CSV table
- Join Field is the join column from the CSV table (identified in step 3)
- Target Field is the join column from the spatial layer (identified in step 3)
- click
OK
- open the attribute table for the spatial layer to see the joined data
- note that joins are temporary
- save the spatial data as a new layer if you want to make the join permanent
No comments:
Post a Comment