- Starting to think about projects and searching for pertinent information
- Devising a model to solve a geographical problem
- Access to spatial and attribute data through the UNBC Library
- Defining Stats Can boundary files and connecting data to them
- Building a query that exemplifies our model
- Visual overlay of data
- Solving a Problem
- Lit Review to get ideas
- Establish a project idea
- Data for the Project
- We are going to example this by:
- Grabbing some Stats Can data
- Calculating population densities
- Exporting our work to Google Earth
Solving a Problem
We have been working toward gaining some understanding of the many aspects of spatial data, and how descriptive information can be linked to these geographical entities. Today we are going to take a break from GIS theory and concentrate on GIS applications. This is where we start to think about the mechanics of applying GIS tools towards your project ideas. In lecture it was mentioned that your projects should be laid out similar to that of an article in a research journal. It is not important what journal you use as a template, as many are laid out in a similar fashion. We will discuss a typical journal layout in a future tutorial. This lab will not be as involved as your project, but it brings together what you have learned so far to aid you in forming an idea of how to approach your project.
The first thing you need to do is review what others have investigated in regards to your topic (or get an idea as to what you may be interested in). This does not suppose that you have already determined your line of investigation but rather is intended to give you direction. It may be wise to look to Google to get a quick idea of possible concepts. For instance look to Google to search out: GIS and: public health, wildlife conservation, archaeology, or anything else that interests you.
Here is a two-part assignment question to get you going:
Question 1 (1 mark):
Part 1: Who is Dr. John Snow and what contribution did he make towards epidemiology and illustrating GIS before its modern digital use (0.5 marks)?
Part 2: Now do a literature search through articles in the library for an article by Timothy Nyerges about GIS and society. Note the authors and publication date in your answer (0.5 marks).
Devising a Project
We will work with Stats Canada data to test a simple theory of how well distributed hospital locations are in regards to preconceived medical notions. We are going to assume that we have done our background research (lit review) and we are going to build a model based on population descriptors expressed spatially. We are going to look at the distribution of people within parcels of B.C. We then will look at the distribution of hospitals in these areas.
- Make a folder lab5 for today’s lab
- Open up QGIS, go to L:/GEOG204/lab5 and load up the two datasets listed below
- – dabc
- – hospital
Arrange your layer manager (theme manager) so that both layers are visible.
Check out the illustrated glossary to find a description of this census layer (see Question 2 below) at Stats Can illustrated glossary > Dissemination Area > Dissemination Area (in the Dictionary, Census of Population, 2016). We reviewed these small area stats can boundaries in last weeks’ lecture, and we will review these more in our next lecture.
Question 2 (1 mark): What is DA an acronym for (0.25 marks)? What parts are combined to record a DA as a geographic code (0.25 marks)? Provide an example code for a DA in Prince George (0.5 marks). Dissemination area: Detailed definition
Aggregation of Stats Can data (a different geographical level of Stats Can data)
We will be taking a second look at how Stats Can boundaries are related in lecture, but today we will use attributes to get a better understanding of how smaller units can be aggregated to larger census units.
We can use several methods to aggregate individual DA units into larger community based conglomerates (such as Fraser Fort George Regional District), which can help us determine the population ratios that hospitals have to support. Today we are going to use the table joins and thematic maps. In the next tutorial we use methods that may be more difficult but are very useful to know.
Before we aggregate data, review the attribute table for the dabc layer. What are the items in this table? Do they have some meaning to you? Can you determine which fields in the data set have unique identifiers and what they are? Can you determine if this identifier is a character (text) type or numeric type (by looking to see which side of the cell the values are aligned with)? If you chose the “DAUID” as the unique ID based on your knowledge of Stats Can geography naming – does it work as a UID in a GIS table (are all the values unique)?
Zoom into Prince George. Use the information button or the select feature tool – and click on a DA unit in the city.
Question 3). Three parts for 2 marks
Some of the DAUID values are not unique – why is that?
HINT: In the attribute table find two DAUID values that are the same, highlight them both (remember that you can hold the ctrl key to select multiple values), then zoom to the selected values (there is a zoom to selected button) (0.5 marks)
Why are there ‘NULL’ values for DAUID and other attributes?
HINT: What is one of the cons of using DA units for research? (0.5 marks)
Based on the DAUID value, determine the Census Division (CD) value for Prince George (0.5 marks). From this, explain how to aggregate all the DA units into a single Census Division (as a selection or shapefile) based on the DAUID (the concepts, not the QGIS commands). HINT: Check out the Dissolve tool in the Processing toolbox (0.5 marks).
HINT: Write up the steps you take below:
Using the query function to aggregate DA units to a CD unit
We need to use the query functions (‘Select Features Using an Expression’) in the attribute table for the “dabc” layer. Your lab instructor will demonstrate – as you have not queried in QGIS before. There are some helpful hints for this such as:
- With numeric columns (aligned to the right), you can use operators such as > or < with the conjunction operator ‘AND’ to squeeze out the Fraser Fort George Polygons’. As an example if the PRCD was 1234 we could use the expression:
"DAUID" >= 12340000 AND "DAUID" < 12350000
- you can use the operator ‘LIKE’ to compare a field to character values the % acts a wild card (can be any character); as such you can enter the part that will be consistent, followed by the wildcard.
"DAUID" LIKE 'PRCD%'
- another way to query is to use the column filter (in the pull down menu in the bottom left) for DAUID and just type in the value you are searching for. Once you have performed the query and selected the values from the table – you should have something that looks like this:
Saving your selection
Save this newly created subset (the Fraser Fort George CD, 5953) as a new shapefile in your directory.
See if you can determine how to export to this selection to a new file, otherwise ask for help.
New Boundary data and Attributes for your aggregation
We downloaded census attribute data in tutorial this week (for the Fraser Fort George Regional District) through the use of the census analyzer. You can practice this now if you wish. For today’s lab we will use the data that you’ll download in the next section.
For this lab we will use all of statistics for B.C. to match to the new Fraser Fort George CD. Can we do this? The table from Stats Can will have many more records (rows) than the attribute table for the CD layer.
Download a Boundary file for the lab from Stats Can
There are many pages on the Stats Can site, and navigation to find specific data can be a bit daunting. It is easy to find a link to the Boundary files by just doing a Google search for them. We are interested in:
- 2016 boundary files for Dissemination Areas
- the English data
- in shapefile format (.shp)
- you can download either the boundary or cartographic file
Once you download the data (a compressed zip file) into your lab3 folder:
- navigate to the file
- right click to decompress the files into your lab 3 folder
- add the new data layer into QGIS
Zoom back into the area around PG. Notice the difference between the shapes of the polygons between the layer you loaded from the lab folder to the new file you have downloaded.
Subset the BC DA polygons
The census data gathered for the section below is for BC only, but the census data we just downloaded is for all of Canada. With this in mind, we should create a new shapefile from the downloaded dataset that has only the BC polygons.
We are not going to tell you how to do this – as this action is very similar to the steps you took to perform the extraction of the Fraser Fort George polygons above (except easier).
Once you have extracted your BC subset, remove the census data layer for all of Canada from your project to help with later steps.
Joining census values to boundary files
To keep us all on the same page, we will use the data prepared for the lab (a non-spatial *.csv file for importing into QGIS like we did in the first lab).
Add da_pop_all_of_bc.csv from L:\GEOG204\lab5\census_data
into your project, and join the two tables together (your new CD layer and the CSV file) in the following manner:
- Right click on the subset layer you created from the Canada-wide census data and open its properties
- Go to the joins tab
- select the layer to join and the fields to join on (see screenshot below)
- Choose the fields that are joined to the table (“Joined fields” tab)
- Set the “Custom field name prefix” to be empty as the image shows below:
Calculate population density
Once you have joined the data together – open the data and observe that some of the population values are “0 or n/a”. What could create these values in a DA census set?
Clean your data to remove “n/a” value
Now that you are a great query builder, find any polygons that have an “n/a” value and delete them (don’t forget to Toggle Editing Mode). Once selected you can hit the red garbage can to delete the row, then save your edits.
Calculating the area of your DA polygons
We also need an area for the polygons to calculate population density.
This can be accomplished by the following steps
- Open the attribute table of your layer
- Find the field calculator button and launch the calculator
- Set up a new field called Area as a decimal number with an output length of “20” and precision of “2”
- Use the “$area” geometry function to populate this column
- Use the image below as your guide
Calculate population density
Now that you have population values and area, calculate the population density of the polygons in square kilometers by:
- opening up the field calculator and create a new field
- create the new field called popdense
- Decimal number with precision “2”
- use the calculation
- pop / (area /1000000)
Save your edits to the shapefile.
Export your results to Google Earth
Style your Census Division values
As you did in the first lab, style your BC DA layers using the “categorized” option with your population field as the field to classify with. Here is a quick reminder as to how to do this:
- Right click –> properties
- Click the symbology tab and switch to categorized from single symbol
- Use the CDUID column
- Hit classify
- Apply and OK
This is really not a good looking map, but it will work for what we need to do today. A better map would be to use the graduated styling method using the population values. In order to do this, you would need to change the population values to integers instead of text values.
Export the data to Google Earth
You can export data to Google Earth (KML file) at any time using the right click –> save as method – BUT this method does not save the styling for polygons. We are going to use another plugin to get the styling as well.
Plugins: Add the plugin mmqgis to your project
Here are the steps to export the map to Google Earth
- Add the mmqgis plugin as usual
- Click mmqgis menu –> Import/Export –> Google Maps KML Export
- Choose the CDUID as the Name Field
- Set your filename and save location to your K: drive
- Click APPLY
- Wait until the bar turns blue giving you the number of polygons
- Hit CLOSE
Now Open up Google Earth and load the KML file into it
- Open Google Earth –> Menu –> Internet –> Google Earth
- File –> Open –> browse to your KML file
Question 4: 1 Mark
Take a screenshot of your Google Earth creation and paste it into your word file for this week’s lab assignment.
Assignment #5 – 5% due next week
- Save the answers for the 4 questions for this lab in a Word document labelled as lastname_firstname_geog204_A5.
- Submit your file by email to your TA by next week’s lab session.