All usefull data must be downloaded from https://s3-us-west-2.amazonaws.com/remotepixel-pub/data/IMW/IMW2018_QGIS_data_processing.zip
- Extract from Canada 2016 Census for Manitoba and Saskatchewan
da.shp
: Dissemination Area definition
Small area composed of one or more neighbouring dissemination blocks, with a population of 400 to 700 persons. All of Canada is divided into dissemination areas.
population.csv
: 2016 Census extract for population number over Manitoba and Saskatchewan (ref)
For this workshop I'm using QGIS 3.2.2 (Bonn) under MacOS, but you should be able to reproduce every steps with older QGIS version.
- Profile tool
- mmqgis
Install plugins:
Plugins > Manage and Install Plugin
- Type
mmgis
in the search bar - Select
mmgis
and clickInstall
drag&drop
or use theBrowser
panel
Right click on the layer > Zoom to Layer
- Create NDVI (vegetation index) dataset (Wiki)
- Change data display
- Visualize profile
Raster > Raster Calculator
(top Menu)- Write expression in
Raster calculator expression
((NIR - R)/(NIR + R)
, withB08.tif
asNIR
andB04.tif
asR
)
Right click on the layer > Properties > Symbology > Render type > Singleband pseudocolor
- Set min/max to
-1 to +1
(by NDVI definition) - Choose Min Max color for
Color ramp
- Click on
Classify
Plugins > Profile Tool > Terrain profile
(top Menu)
Make sure to select NDVI
layer (we created in step 2.1)
Layer > Create Layer > New Shapefile Layer
(top Menu)
- Select
Line
geometry type
This will create an empty layer.
- Allow layer edition:
Right click > Toggle Editing
orLayer > Toggle Editing
(top Menu) - Start tracing
Add Line Feature
in theDigitizing Toolbar
(View > Toolbar > Digitizing Toolbar
)
-
Finish tracing by doing a
Right click
-
Inspect the newly create feature
- Load and visualize data
- Extract Manitoba limits data
- Merge Census CSV data with limits data
- Explore Expression filtering/calculator
Data pre-processing (Optional)
# Download Census CSV for Prairies
wget http://www12.statcan.gc.ca/census-recensement/2016/dp-pd/prof/details/download-telecharger/comp/GetFile.cfm?Lang=E&TYPE=CSV&GEONO=044_PRAIRIES
# Extract population data
cat 98-401-X2016044_PRAIRIES_English_CSV_data.csv | grep "\"Population, 2016\"" >98-401-X2016044_PRAIRIES_English_CSV_data_population.csv
# Extract CSV header
head -n 1 98-401-X2016044_PRAIRIES_English_CSV_data.csv > header.csv
# merge header and population data
cat header.csv 98-401-X2016044_PRAIRIES_English_CSV_data_population.csv > population.csv
Each DA
features has 3 attributes:
- DAUID: Dissemnination Area ID
- PRUID: Province ID
- PRNAME: Province Name
After loading the data, we want to create a new layer with only Manitoba DA.
Right click on layer > Open Attribute Table
- Click on
Select features using an expression
- Write expression
"PRNAME"='Manitoba'
and clickSelect features
- Save selection to a new Shapefile
Click right on layer > Export > Save Selected Features As...
The Census data has population info for each DA but in the CSV the DA
ID is called GEO_CODE (POR)
MMQGIS > Combine > Attribute Join from CSV File
- Inputs:
population.csv
GEO_CODE (POR)
for the CSV fieldManitoba DA
as input layer (the one we created in 3.1)DAUID
joint layer attribute
We now have a new layer with both info from da.shp
and population.csv
Right click on layer > Open Table Attribute > Open Field Calculator
Note:
- The Census data header being verry long, the population attribute in the shapefile is called
Dim_ Sex(
- When importing the CSV data, QGIS didn't recognize the population value as integer but as string
The Population density equation is then: to_int("Dim_ Sex(") / $area
to_int
is a QGIS function to cast a value to integer$area
is a QGIS special variable name pointing to the feature area
Right click on layer > Properties > Symbology > Graduated
- Select
POPDENS
attibute - Because the Population is maily centered in Winipegs, using
Quantile
mode will create better color distribution - Click on
Classify
Manitoba population density map
We now have a population dataset and the track of the Tornado we extracted for the Sentinel2 imagery, let's try to extract the total population number in the tornado surrounding area.
MMQGIS > Combine > Spatial Join
- Inputs:
tornado_track
is the target layer- Use
Intersects
as spatial operation - Extract data from
manitoba_da.shp
Sum
intersecting value forDim_ Sec(
attribute
Results: The tornado affected 2 DA affecting a maximum of 458 people.