For PA4 you’ll be overlaying data onto a georectified map. This tutorial shows you how to upload the vector shapefile for Davidson College, how to create your own vector shapefiles, and how to attach non-geographic data to those shapefiles.
Importing the Davidson shapefile
In the description for PA4, you’ll find a link to Davidson shapefiles. Download them all, and place them in a folder called Davidson.
Open QGIS and add a vector layer:
Select Davidson_buildings.shp and also upload Davidson_roads.shp
Once you’ve uploaded your shapefile, it should appear in the main area of QGIS. I’ve projected these shapefiles in WGS84, but check to make sure that the CRS is set properly.
First, right-click on the Davidson shapefile. Scroll down to Set Layer CRS, and select WGS84.
Your map might disappear, but fear not! You also have to set the project CRS to match the layer you just imported. Right-click on the layer again, and select “Set Project CRS from Layer”
If you still don’t see your map, click the check-box next to your layer, go to View>Zoom to Layer. Your map should appear.
Overlaying your map
Now that you have a base map, you can overlay your own map. If you need a refresher in georectifying in QGIS, go back to the QGIS tutorial from earlier in the semester. You can either input Longitude and Latitude coordinates or, if your map has features that are recognizable today, you can try to match them by hand, as we did with MapTiler.
For instance, if since the Davidson shapefile has Chambers clearly marked, I could insert a reference point in the center of Chambers
But instead of entering longitude and latitude points, I could click on “From map canvas” and estimate the same place in the middle of the Chambers on my base map.
Once you have georeferenced your map, it should automatically appear on the canvas, on top of the Davidson shapefile. If it doesn’t check to make sure that all of your maps are using the same CRS.
When you’re finished, you can play with the transparency of your georectified map by double clicking and adjusting the transparency slider bar. When finished, you should have something like this:
There are a few ways to overlay data on to your map: adding points, assigning information to shapefiles that someone else created, or assigning information to shapefiles you create. We’re going to walk through the first and last approaches here – for a refresher on the middle one go back to the choropleth map tutorial.
One way to get data on to your map is simply to upload a spreadsheet that contains some kind of non-geographic data paired with Lat/Long data.
You can use the dorm data linked in PA4, or create your own spreadsheet. Save as a comma separated file – the file type should be .csv
(If you’re working on a mac, sometimes the .csv files don’t upload properly. To fix the problem, save your file as “Windows Comma Separated”)
In QGIS, go to Layer>Add Delimited Text Layer and select your file.
Set X field to Longitude and Y field to Latitude. If you don’t see those options in the drop-down menu, make sure that “Number of header lines to discard” is set to 0.
Click OK, and select the appropriate CRS.
Congrats, you’ve now put data on the map!
Double click on the layer name to play around with labels, colors, etc.
But, say you wanted to do more than just put some points on a map. Say you wanted to represent the percentage of African-American students in each dorm. To do that, we need to create some shapes to fill with different colors.
To do that, you need to create a new shapefile layer.
This is going to be a layer composed of polygons, so select polygon, make sure the CRS is set to WGS 84 and add whatever attributes you think are important. In this case, you could either hand enter all of the data from the Dorm Data document, or create a linking category, that allows us to merge the dorm data table with our shapefile. Let’s create a category called BLDGNUM and add it to the attributes list.
Create a folder and name the shapefile something like dormdata.
Now we can start making some polygons.
Highlight the layer we’re going to be making. Then right-click and toggle editing.
Now click on the add feature tool.
Use this tool to define the corners of a shape. So, for a dorm, click on all of the corners until the red area covers the shape you want. Then move the cursor inside the red area and right-click.
You’ll be asked to enter information. This is where we need to make sure that each building has the right code associated with it. So we would open the dormdata .csv file, and when we traced Belk, for instance, we’d make sure that the BLDGNUM is 4. Same for the others. When you are finished making these shapes, toggle editing off.
Once you’ve created all of the shapefiles for all of the dorms, you can merge data like we did with the U.S. unemployment data.