Joining a shapefile attribute table to a CSV file
Joining attribute tables to other database tables allows you to use a spatial dataset in order to reference a dataset without any geometry, using a common key between the data tables. A very common use case for this is to join a vector dataset of census attributes to a more detailed census attribute dataset. The use case we will demonstrate here links a US census track file to a detailed CSV file that contains more in-depth information.
Getting ready
For this recipe, you will need a census tract
shapefile and a CSV file containing the appropriate census data for the shapefile. You can download the sample data set from https://geospatialpython.googlecode.com/svn/census.zip.
Extract this data to a directory named /qgis_data/census
.
How to do it...
The join operation is quite involved. We'll perform this operation and save the layer as a new shapefile with the joined attributes. Then we'll load the new layer and compare the field count to the original...