Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

  1. add the spatial data to the view in QGIS
  2. 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)
  3. 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
  4. add the CSV file to QGIS by clicking (on the menu) Layer > Add Vector Layer
    • the table should appear in the Table of Contents
  5. 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
  6. double-click on the spatial data layer to open Properties
  7. click the Joins tab
  8. 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
  9. open the attribute table for the spatial layer to see the joined data
  10. note that joins are temporary
    • save the spatial data as a new layer if you want to make the join permanent
share|improve this answer
    
great, it worked. thanks a lot –  Martin Jul 10 '13 at 12:52
    
@Martin great! I'm glad it helped. Will you please mark the answer as accepted so future readers will know it worked? –  user3461 Jul 10 '13 at 13:16
    
Ok, I checked, thanks again. I never thought that you can add a csv table by using the "add vector layer" button ;) –  Martin Jul 15 '13 at 15:27
    
Thanks. Yeah, it seems like an odd menu location for adding a CSV, but maybe it was the best fit. –  user3461 Jul 15 '13 at 16:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.