Section 7 Exercises
7.1 Exercise 1: Determine the area fraction of urban heat islands by boroughs of Montreal
The aim of this exercise is to generate a choropleth map showing the area fraction of urban heat islands by boroughs of Montreal.
Figure 7.1: Area fraction of UHI by boroughs
- Import
ilotschaleur.json
andlimadmim_clipped.shp
.
Figure 7.2: UHI and boroughs of Montreal
Export
ilotschaleur.json
as a shapefile and save it asilotschaleur.shp
(Section 3.4).Intersect the recently created layer
ilotschaleur.shp
withlimadmim_clipped.shp
. Navigate to Vector, select Geoprocessing Tools, and the Intersection (Section 5.2). Set the following parameters:
- Input layer:
ilotschaleur.shp
- Overlay layer:
limadmim_clipped.shp
The aim is to generate a new layer in which the urban heat islands are divided according to Montreal’s boroughs.
Figure 7.3: Intersection of layers
Click Run to execute the algorithm. However, it will stop since there are some invalid geometries in the input layer.
Figure 7.4: Error: Intersection of layers
- We will use the Fix Geometries algorithm from the Processing Toolbox to fix the geometries. Run the algorithm according to the following settings.
Figure 7.5: Fix geometries algorithm
A temporary layer will be generated after running the algorithm. Right click on layer Fixed geometries
and rename it ilotschaleur_fixed
.
- Run again the Intersection algorithm, but this time use the fixed layer of urban heat islands. Set the following parameters:
- Input layer:
ilotschaleur_fixed.shp
- Overlay layer:
limadmim_clipped.shp
Figure 7.6: Intersection of layers
A temporary layer Intersection
will be generated after running the algorithm. To verify that the algorithm has properly worked, open the attribute table and you will notice that the Intersection
layer has 584 attributes, whereas the ilotschaleur_fixed
has 498.
- Dissolve the
Intersection
layer by NOM. The aim is to combine the polygons corresponding to the same borough, which is given by the NOM field. In the Dissolve field(s), click on the … and select NOM.
Figure 7.7: Dissolve Intersection layer by NOM
After running the Dissolve algorithm, a temporary layer Dissolved
will be generated. Open the attribute table of this layer and verify that it has 33 attributes; whereas the Intersection
layer has 584. The task of combining the polygons has been accomplished.
- Calculate the area of the urban heat islands by boroughs.
First of all, we will delete the fields of the Dissolved
layer that will not be used. Open the attribute table, then click on the pencil shown in the left corner (Toggle editing mode) to allow editing the attribute table. Click on Delete field and select the fields shown in the following figure:
Figure 7.8: Delete some fields of Dissolved layer
We will now calculate the area of the urban heat islands by borough. Click on New field. In the window that will display, select Create a new field, indicate AREA in the Output field name, set Decimal number (real) as the Output field type. Double click on $area from the center panel.
Figure 7.9: Calculate the area of UHI
- Join the AREA of the urban heat islands (
Dissolved
layer) to the respective borough in thelimadmim_clipped.shp
layer. The prefix UHA_ was set to distinguish the fields from the joined layer.
Figure 7.10: Join layers
- Calculate the fraction area of urban heat islands (UHI) by boroughs.
First, calculate the AREA of each borough from the limadmim_clipped.shp
layer. Click on New field. In the window that will display, select Create a new field, indicate AREA in the Output field name, set Decimal number (real) as the Output field type. Double click on $area from the center panel.
Figure 7.11: Calculate the area of Montreal’s boroughs
Finally, calculate the area fraction of UHI. In the center panel, go to Fields and Values, double click to select the involved fields in the computation of the new one. In this case, the area fraction is given by the expression: FRAC_UHA = UHA_AREA/AREA
Note: UHI was misspelled. So UHA stand for UHI.
Figure 7.12: Calculate the area fraction of UHI
- Style the
limadmim_clipped.shp
layer so that it shows the area fraction of UHI in four classes of equal interval.
Right click on limadmim_clipped.shp
, select Properties, then Symbology, and set the parameters according to the following figure.
Figure 7.13: Changing the symbology of a layer