Skip to content

Latest commit

 

History

History
893 lines (713 loc) · 33.7 KB

File metadata and controls

893 lines (713 loc) · 33.7 KB

Lesson: Supplementary Exercise

In this lesson, you will be guided through a complete GIS analysis in QGIS.

Note

Lesson developed by Linfiniti Consulting (South Africa) and Siddique Motala (Cape Peninsula University of Technology)

Problem Statement

You are tasked with finding areas in and around the Cape Peninsula that are suitable habitats for a rare fynbos plant species. The extent of your area of investigation covers Cape Town and the Cape Peninsula between Melkbosstrand in the north and Strand in the south. Botanists have provided you with the following preferences exhibited by the species in question:

  • It grows on east facing slopes
  • It grows on slopes with a gradient between 15% and 60%
  • It grows in areas that have a total annual rainfall of > 1000 mm
  • It will only be found at least 250 m away from any human settlement
  • The area of vegetation in which it occurs should be at least 6000 ㎡ in area

As a student at the University, you have agreed to search for the plant in four different suitable areas of land. You want those four suitable areas to be the ones that are closest to the University of Cape Town where you live. Use your GIS skills to determine where you should go to look.

Solution Outline

The data for this exercise can be found in the :file:`exercise_data/more_analysis` folder.

You are going to find the four suitable areas that are closest to the University of Cape Town.

The solution will involve:

  1. Analyzing a DEM raster layer to find the east facing slopes and the slopes with the correct gradients
  2. Analyzing a rainfall raster layer to find the areas with the correct amount of rainfall
  3. Analyzing a zoning vector layer to find areas that are away from human settlement and are of the correct size

Follow Along: Setting up the Map

  1. Click on the projectionEnabled Current CRS button in the lower right corner of the screen. Under the :guilabel:`CRS` tab of the dialog that appears, use the "Filter" tool to search for "33S". Select the entry :guilabel:`WGS 84 / UTM zone 33S` (with EPSG code 32733).

  2. Click :guilabel:`OK`

    img/crs.png

    Setting up the CRS

  3. Save the project file by clicking on the fileSave Save Project toolbar button, or use the :menuselection:`Project --> Save As...` menu item.

    Save it in a new directory called :file:`Rasterprac`, that you should create somewhere on your computer. You will save whatever layers you create in this directory as well. Save the project as :file:`your_name_fynbos.qgs`.

Loading Data into the Map

In order to process the data, you will need to load the necessary layers (street names, zones, rainfall, DEM, districts) into the map canvas.

For vectors...

  1. Click on the dataSourceManager Open Data Source Manager button in the Data Source Manager Toolbar, and enable the addOgrLayer :guilabel:`Vector` tab in the dialog that appears, or use the :menuselection:`Layer --> Add Layer -->` addOgrLayer :menuselection:`Add Vector Layer...` menu item

  2. Ensure that radioButtonOn :guilabel:`File` is selected

  3. Click on the :guilabel:`...` button to browse for vector dataset(s)

  4. In the dialog that appears, open the :file:`exercise_data/more_analysis/Streets` directory

  5. Select the file :file:`Street_Names_UTM33S.shp`

  6. Click :guilabel:`Open`.

    The dialog closes and shows the original dialog, with the file path specified in the text field next to :guilabel:`Vector dataset(s)`. This allows you to ensure that the correct file is selected. It is also possible to enter the file path in this field manually, should you wish to do so.

  7. Click :guilabel:`Add`. The vector layer will be loaded into your map. Its color is automatically assigned. You will change it later.

  8. Rename the layer to Streets

    1. Right-click on it in the :guilabel:`Layers` panel (by default, the pane along the left-hand side of the screen)
    2. Click :guilabel:`Rename` in the dialog that appears and rename it, pressing the Enter key when done
  9. Repeat the vector adding process, but this time select the :file:`Generalised_Zoning_Dissolve_UTM33S.shp` file in the :file:`Zoning` directory.

  10. Rename it to Zoning.

  11. Load also the vector layer :file:`admin_boundaries/Western_Cape_UTM33S.shp` into your map.

  12. Rename it to Districts.

For rasters...

  1. Click on the dataSourceManager Open Data Source Manager button and enable the addRasterLayer :guilabel:`Raster` tab in the dialog that appears, or use the :menuselection:`Layer --> Add Layer -->` addRasterLayer :menuselection:`Add Raster Layer...` menu item
  2. Ensure that radioButtonOn :guilabel:`File` is selected
  3. Navigate to the appropriate file, select it, and click :guilabel:`Open`
  4. Do this for each of the following two raster files, :file:`DEM/SRTM.tif` and :file:`rainfall/reprojected/rainfall.tif`
  5. Rename the SRTM raster to DEM and the rainfall raster to Rainfall (with an initial capital)

Changing the layer order

Click and drag layers up and down in the :guilabel:`Layers` panel to change the order they appear in on the map so that you can see as many of the layers as possible.

Now that all the data is loaded and properly visible, the analysis can begin. It is best if the clipping operation is done first. This is so that no processing power is wasted on computing values in areas that are not going to be used anyway.

Find the Correct Districts

Due to the aforementioned area of investigation, we need to limit our districts to the following ones:

  • Bellville
  • Cape
  • Goodwood
  • Kuils River
  • Mitchells Plain
  • Simon Town
  • Wynberg
  1. Right-click on the Districts layer in the :guilabel:`Layers` panel.

  2. In the menu that appears, select the :guilabel:`Filter...` menu item. The :guilabel:`Query Builder` dialog appears.

  3. You will now build a query to select only the candidate districts:

    1. In the :guilabel:`Fields` list, double-click on the NAME_2 field to make it appear in the :guilabel:`SQL where clause` text field below

    2. Click the :guilabel:`IN` button to append it to the SQL query

    3. Open the brackets

    4. Click the :guilabel:`All` button below the (currently empty) :guilabel:`Values` list.

      After a short delay, this will populate the :guilabel:`Values` list with the values of the selected field (NAME_2).

    5. Double-click the value Bellville in the :guilabel:`Values` list to append it to the SQL query.

    6. Add a comma and double-click to add Cape district

    7. Repeat the previous step for the remaining districts

    8. Close the brackets

    img/query_builder.png

    Query builder

    The final query should be (the order of the districts in the brackets does not matter):

    "NAME_2" in ('Bellville', 'Cape', 'Goodwood', 'Kuils River',
                 'Mitchells Plain', 'Simon Town', 'Wynberg')
    

    Note

    You can also use the OR operator; the query would look like this:

    "NAME_2" = 'Bellville' OR "NAME_2" = 'Cape' OR
    "NAME_2" = 'Goodwood' OR "NAME_2" = 'Kuils River' OR
    "NAME_2" = 'Mitchells Plain' OR "NAME_2" = 'Simon Town' OR
    "NAME_2" = 'Wynberg'
    
    1. Click :guilabel:`OK` twice.

      The districts shown in your map are now limited to those in the list above.

Clip the Rasters

Now that you have an area of interest, you can clip the rasters to this area.

  1. Open the clipping dialog by selecting the menu item :menuselection:`Raster --> Extraction --> Clip Raster by Mask Layer...`

  2. In the :guilabel:`Input layer` dropdown list, select the DEM layer

  3. In the :guilabel:`Mask layer` dropdown list, select the Districts layer

  4. Scroll down and specify an output location in the :guilabel:`Clipped (mask)` text field by clicking the :guilabel:`...` button and choosing :guilabel:`Save to File...`

    1. Navigate to the :file:`Rasterprac` directory
    2. Enter a file name - DEM_clipped.tif
    3. Save
  5. Make sure that checkbox :guilabel:`Open output file after running algorithm` is checked

  6. Click :guilabel:`Run`

    After the clipping operation has completed, leave the :guilabel:`Clip Raster by Mask Layer` dialog open, to be able to reuse the clipping area

  7. Select the Rainfall raster layer in the :guilabel:`Input layer` dropdown list and save your output as :file:`Rainfall_clipped.tif`

  8. Do not change any other options. Leave everything the same and click :guilabel:`Run`.

  9. After the second clipping operation has completed, you may close the :guilabel:`Clip Raster by Mask Layer` dialog

  10. Save the map

    img/clipped_r_filtered_v_reordered_l.png

    Map view with filtered vector, clipped raster and reordered layers

Align the rasters

For our analysis we need the rasters to have the same CRS and they have to be aligned.

First we change the resolution of our rainfall data to 30 meters (pixel size):

  1. In the :guilabel:`Layers` panel, ensure that Rainfall_clipped is the active layer (i.e., it is highlighted by having been clicked on)

  2. Click on the :menuselection:`Raster --> Projections --> Warp (Reproject)...` menu item to open the :guilabel:`Warp (Reproject)` dialog

  3. Under :guilabel:`Resampling method to use`, select :guilabel:`Bilinear (2x2 kernel)` from the drop down menu

  4. Set :guilabel:`Output file resolution in target georeferenced units` to 30

  5. Scroll down to :guilabel:`Reprojected` and save the output in your :file:`rainfall/reprojected` directory as :file:`Rainfall30.tif`.

  6. Make sure that checkbox :guilabel:`Open output file after running algorithm` is checked

    img/wrap_rainfall.png

    Warp (Reproject) Rainfall_clipped

Then we align the DEM:

  1. In the :guilabel:`Layers` panel, ensure that DEM_clipped is the active layer (i.e., it is highlighted by having been clicked on)
  2. Click on the :menuselection:`Raster --> Projections --> Warp (Reproject)...` menu item to open the :guilabel:`Warp (Reproject)` dialog
  3. Under :guilabel:`Target CRS`, select :guilabel:`Project CRS: EPSG:32733 - WGS 84 / UTM zone 33S` from the drop down menu
  4. Under :guilabel:`Resampling method to use`, select :guilabel:`Bilinear (2x2 kernel)` from the drop down menu
  5. Set :guilabel:`Output file resolution in target georeferenced units` to 30
  6. Scroll down to :guilabel:`Georeferenced extents of output file to be created`. Use the button to the right of the text box to select :menuselection:`Calculate from Layer --> Rainfall30`.
  7. Scroll down to :guilabel:`Reprojected` and save the output in your :file:`DEM/reprojected` directory as :file:`DEM30.tif`.
  8. Make sure that checkbox :guilabel:`Open output file after running algorithm` is checked

In order to properly see what's going on, the symbology for the layers needs to be changed.

Changing the symbology of vector layers

  1. In the :guilabel:`Layers` panel, right-click on the Streets layer
  2. Select :guilabel:`Properties` from the menu that appears
  3. Switch to the :guilabel:`Symbology` tab in the dialog that appears
  4. Click on the :guilabel:`Line` entry in the top widget
  5. Select a symbol in the list below or set a new one (color, transparency, ...)
  6. Click :guilabel:`OK` to close the :guilabel:`Layer Properties` dialog. This will change the rendering of the Streets layer.
  7. Follow a similar process for the Zoning layer and choose an appropriate color for it

Changing the symbology of raster layers

Raster layer symbology is somewhat different.

  1. Open the :guilabel:`Properties` dialog for the Rainfall30 raster layer

  2. Switch to the :guilabel:`Symbology` tab. You'll notice that this dialog is very different from the version used for vector layers.

  3. Expand :guilabel:`Min/Max Value Settings`

  4. Ensure that the button :guilabel:`Mean +/- standard deviation` is selected

  5. Make sure that the value in the associated box is 2.00

  6. For :guilabel:`Contrast enhancement`, make sure it says :guilabel:`Stretch to MinMax`

  7. For :guilabel:`Color gradient`, change it to :guilabel:`White to Black`

  8. Click :guilabel:`OK`

    img/raster_symbology.png

    Raster symbology

    The Rainfall30 raster, if visible, should change colors, allowing you to see different brightness values for each pixel

  9. Repeat this process for the DEM30 layer, but set the standard deviations used for stretching to 4.00

Clean up the map

  1. Remove the original Rainfall and DEM layers, as well as Rainfall_clipped and DEM_clipped from the :guilabel:`Layers` panel:

    • Right-click on these layers and select :guilabel:`Remove`.

      Note

      This will not remove the data from your storage device, it will merely take it out of your map.

  2. Save the map

  3. You can now hide the vector layers by unchecking the box next to them in the :guilabel:`Layers` panel. This will make the map render faster and will save you some time.

Create the hillshade

In order to create the hillshade, you will need to use an algorithm that was written for this purpose.

  1. In the :guilabel:`Layers` panel, ensure that DEM30 is the active layer (i.e., it is highlighted by having been clicked on)

  2. Click on the :menuselection:`Raster --> Analysis --> Hillshade...` menu item to open the :guilabel:`Hillshade` dialog

  3. Scroll down to :guilabel:`Hillshade` and save the output in your :file:`Rasterprac` directory as :file:`hillshade.tif`

  4. Make sure that checkbox :guilabel:`Open output file after running algorithm` is checked

  5. Click :guilabel:`Run`

  6. Wait for it to finish processing.

    img/hillshade.png

    Raster analysis Hillshade

The new hillshade layer has appeared in the :guilabel:`Layers` panel.

  1. Right-click on the hillshade layer in the :guilabel:`Layers` panel and bring up the :guilabel:`Properties` dialog
  2. Click on the :guilabel:`Transparency` tab and set the :guilabel:`Global Opacity` slider to 20%
  3. Click :guilabel:`OK`
  4. Note the effect when the transparent hillshade is superimposed over the clipped DEM. You may have to change the order of your layers, or click off the Rainfall30 layer in order to see the effect.

Slope

  1. Click on the :menuselection:`Raster --> Analysis --> Slope...` menu item to open the :guilabel:`Slope` algorithm dialog

  2. Select DEM30 as :guilabel:`Input layer`

  3. Check checkbox :guilabel:`Slope expressed as percent instead of degrees`. Slope can be expressed in different units (percent or degrees). Our criteria suggest that the plant of interest grows on slopes with a gradient between 15% and 60%. So we need to make sure our slope data is expressed as a percent.

  4. Specify an appropriate file name and location for your output.

  5. Make sure that checkbox :guilabel:`Open output file after running algorithm` is checked

  6. Click :guilabel:`Run`

    img/slope.png

    Raster analysis Slope

The slope image has been calculated and added to the map. As usual, it is rendered in grayscale. Change the symbology to a more colorful one:

  1. Open the layer :guilabel:`Properties` dialog (as usual, via the right-click menu of the layer)
  2. Click on the :guilabel:`Symbology` tab
  3. Where it says :guilabel:`Singleband gray` (in the :guilabel:`Render type` dropdown menu), change it to :guilabel:`Singleband pseudocolor`
  4. Choose :guilabel:`Mean +/- standard deviation x` for :guilabel:`Min / Max Value Settings` with a value of 2.0
  5. Select a suitable :guilabel:`Color ramp`
  6. Click :guilabel:`Run`

Try Yourself: Aspect

Use the same approach as for calculating the slope, choosing :guilabel:`Aspect...` in the :menuselection:`Raster --> Analysis` menu.

Remember to save the project periodically.

Reclassifying rasters

  1. Choose :menuselection:`Raster --> Raster calculator...`

  2. Specify your :file:`Rasterprac` directory as the location for the :guilabel:`Output layer` (click on the :guilabel:`...` button), and save it as :file:`slope15_60.tif`

  3. Ensure that the :guilabel:`Open output file after running algorithm` box is selected.

    In the :guilabel:`Raster bands` list on the left, you will see all the raster layers in your :guilabel:`Layers` panel. If your Slope layer is called slope, it will be listed as slope@1. Indicating band 1 of the slope raster.

  4. The slope needs to be between 15 and 60 degrees.

    Using the list items and buttons in the interface, build the following expression:

    (slope@1 > 15) AND (slope@1 < 60)
    
  5. Set the :guilabel:`Output layer` field to an appropriate location and file name.

  6. Click :guilabel:`Run`.

    img/raster_calculator_slope.png

    Raster calculator Slope

Now find the correct aspect (east-facing: between 45 and 135 degrees) using the same approach.

  1. Build the following expression:

    (aspect@1 > 45) AND (aspect@1 < 135)
    

You will know it worked when all of the east-facing slopes are white in the resulting raster (it's almost as if they are being lit by the morning sunlight).

Find the correct rainfall (greater than 1000 mm) the same way. Use the following expression:

Rainfall30@1 > 1000

Now that you have all three criteria each in separate rasters, you need to combine them to see which areas satisfy all the criteria. To do so, the rasters will be multiplied with each other. When this happens, all overlapping pixels with a value of 1 will retain the value of 1 (i.e. the location meets the criteria), but if a pixel in any of the three rasters has the value of 0 (i.e. the location does not meet the criteria), then it will be 0 in the result. In this way, the result will contain only the overlapping areas that meet all of the appropriate criteria.

Combining rasters

  1. Open the Raster Calculator (:menuselection:`Raster --> Raster Calculator...`)

  2. Build the following expression (with the appropriate names for your layers):

    [aspect45_135] * [slope15_60] * [rainfall_1000]
    
  3. Set the output location to the :file:`Rasterprac` directory

  4. Name the output raster :file:`aspect_slope_rainfall.tif`

  5. Ensure that checkbox :guilabel:`Open output file after running algorithm` is checked

  6. Click :guilabel:`Run`

The new raster now properly displays the areas where all three criteria are satisfied.

Save the project.

img/aspect_slope_rainfall.png

Map view where all three criteria are satisfied

The next criterion that needs to be satisfied is that the area must be 250 m away from urban areas. We will satisfy this requirement by ensuring that the areas we compute are inside rural areas, and are 250 m or more from the edge of the area. Hence, we need to find all rural areas first.

Finding rural areas

  1. Hide all layers in the :guilabel:`Layers` panel

  2. Unhide the Zoning vector layer

  3. Right-click on it and bring up the :guilabel:`Attribute Table` dialog. Note the many different ways that the land is zoned here. We want to isolate the rural areas. Close the Attribute table.

  4. Right-click on the Zoning layer and select :guilabel:`Filter...` to bring up the :guilabel:`Query Builder` dialog

  5. Build the following query:

    "Gen_Zoning" = 'Rural'
    

    See the earlier instructions if you get stuck.

  6. Click :guilabel:`OK` to close the :guilabel:`Query Builder` dialog. The query should return one feature.

    img/query_builder_zoning.png

    Query builder Zoning

You should see the rural polygons from the Zoning layer. You will need to save these.

  1. In the right-click menu for Zoning, select :menuselection:`Export --> Save Features As...`.
  2. Save your layer under the :file:`Rasterprac` directory
  3. Name the output file :file:`rural.shp`
  4. Click :guilabel:`OK`
  5. Save the project

Now you need to exclude the areas that are within 250m from the edge of the rural areas. Do this by creating a negative buffer, as explained below.

Creating a negative buffer

  1. Click the menu item :menuselection:`Vector --> Geoprocessing Tools --> Buffer...`

  2. In the dialog that appears, select the rural layer as your input vector layer (:guilabel:`Selected features only` should not be checked)

  3. Set :guilabel:`Distance` to -250. The negative value means that the buffer will be an internal buffer. Make sure that the units are meters in the dropdown menu.

  4. Check checkbox :guilabel:`Dissolve result`

  5. In :guilabel:`Buffered`, place the output file in the :file:`Rasterprac` directory, and name it :file:`rural_buffer.shp`

  6. Click :guilabel:`Save`

  7. Click :guilabel:`Run` and wait for the processing to complete

  8. Close the :guilabel:`Buffer` dialog.

    Make sure that your buffer worked correctly by noting how the rural_buffer layer is different from the rural layer. You may need to change the drawing order in order to observe the difference.

  9. Remove the rural layer

  10. Save the project

    img/rural_buffer.png

    Map view with rural buffer

Now you need to combine your rural_buffer vector layer with the aspect_slope_rainfall raster. To combine them, we will need to change the data format of one of the layers. In this case, you will vectorize the raster, since vector layers are more convenient when we want to calculate areas.

Vectorizing the raster

  1. Click on the menu item :menuselection:`Raster --> Conversion --> Polygonize (Raster to Vector)...`

  2. Select the :file:`aspect_slope_rainfall` raster as :guilabel:`Input layer`

  3. Set :guilabel:`Name of the field to create` to suitable (the default field name is DN - Digital number data)

  4. Save the output. Under :guilabel:`Vectorized`, select :guilabel:`Save file as`. Set the location to :file:`Rasterprac` and name the file :file:`aspect_slope_rainfall_all.shp`.

  5. Ensure that checkbox :guilabel:`Open output file after running algorithm` is checked

  6. Click :guilabel:`Run`

  7. Close the dialog when processing is complete

    img/vectorized.png

    Raster to Vector

All areas of the raster have been vectorized, so you need to select only the areas that have a value of 1 in the suitable field. (Digital Number.

  1. Open the :guilabel:`Query Builder` dialog (right-click - :guilabel:`Filter...`) for the new vector layer

  2. Build this query:

    "suitable" = 1
    
  3. Click :guilabel:`OK`

  4. After you are sure the query is complete (and only the areas that meet all three criteria, i.e. with a value of 1 are visible), create a new vector file from the results, using the :menuselection:`Export --> Save Features As...` in the layer's right-click menu

  5. Save the file in the :file:`Rasterprac` directory

  6. Name the file :file:`aspect_slope_rainfall_1.shp`

  7. Remove the aspect_slope_rainfall_all layer from your map

  8. Save your project

When we use an algorithm to vectorize a raster, sometimes the algorithm yields what is called "Invalid geometries", i.e. there are empty polygons, or polygons with mistakes in them, that will be difficult to analyze in the future. So, we need to use the :guilabel:`Fix Geometry` tool.

Fixing geometry

  1. In the :guilabel:`Processing Toolbox`, search for Fix geometries, and :guilabel:`Execute...` it
  2. For the :guilabel:`Input layer`, select aspect_slope_rainfall_1
  3. Under :guilabel:`Fixed geometries`, select :guilabel:`Save file as`, and save the output to :file:`Rasterprac` and name the file :file:`fixed_aspect_slope_rainfall.shp`.
  4. Ensure that checkbox :guilabel:`Open output file after running algorithm` is checked
  5. Click :guilabel:`Run`
  6. Close the dialog when processing is complete

Now that you have vectorized the raster, and fixed the resulting geometry, you can combine the aspect, slope, and rainfall criteria with the distance from human settlement criteria by finding the intersection of the fixed_aspect_slope_rainfall layer and the rural_buffer layer.

Determining the Intersection of vectors

  1. Click the menu item :menuselection:`Vector --> Geoprocessing Tools --> Intersection...`

  2. In the dialog that appears, select the rural_buffer layer as :guilabel:`Input layer`

  3. For the :guilabel:`Overlay layer`, select the fixed_aspect_slope_rainfall layer

  4. In :guilabel:`Intersection`, place the output file in the :file:`Rasterprac` directory

  5. Name the output file :file:`rural_aspect_slope_rainfall.shp`

  6. Click :guilabel:`Save`

  7. Click :guilabel:`Run` and wait for the processing to complete

  8. Close the :guilabel:`Intersection` dialog.

    Make sure that your intersection worked correctly by noting that only the overlapping areas remain.

  9. Save the project

The next criteria on the list is that the area must be greater than 6000 ㎡. You will now calculate the polygon areas in order to identify the areas that are the appropriate size for this project.

Calculating the area for each polygon

  1. Open the new vector layer's right-click menu

  2. Select :guilabel:`Open attribute table`

  3. Click the toggleEditing Toggle editing button in the top left corner of the table, or press Ctrl+e

  4. Click the calculateField Open field calculator button in the toolbar along the top of the table, or press Ctrl+i

  5. In the dialog that appears, make sure that checkbox :guilabel:`Create new field` is checked, and set the :guilabel:`Output field name` to area The output field type should be a decimal number (real). Set :guilabel:`Precision` to 1 (one decimal).

  6. In the :guilabel:`Expression` area, type:

    $area
    

    This means that the field calculator will calculate the area of each polygon in the vector layer and will then populate a new integer column (called area) with the computed value.

    img/field_calculator_area.png

    Field Calculator

  7. Click :guilabel:`OK`

  8. Do the same thing for another new field called id. In :guilabel:`Field calculator expression`, type:

    $id
    

    This ensures that each polygon has a unique ID for identification purposes.

  9. Click toggleEditing Toggle editing again, and save your edits if prompted to do so

    img/attribute_table.png

    Attribute table with area and id columns

Selecting areas of a given size

Now that the areas are known:

  1. Build a query (as usual) to select only the polygons that are larger than 6000 ㎡. The query is:

    "area" > 6000
    
  2. Save the selection in the :file:`Rasterprac` directory as a new vector layer called :file:`suitable_areas.shp`.

You now have the suitable areas that meet all of the habitat criteria for the rare fynbos plant, from which you will pick the four areas that are nearest to the University of Cape Town.

Digitize the University of Cape Town

  1. Create a new vector layer in the :file:`Rasterprac` directory as before, but this time, use :guilabel:`Point` as :guilabel:`Geometry type` and name it :file:`university.shp`

  2. Ensure that it is in the correct CRS (Project CRS:EPSG:32733 - WGS 84 / UTM zone 33S)

  3. Finish creating the new layer (click :guilabel:`OK`)

  4. Hide all layers except the new university layer and the Streets layer.

  5. Add a background map (OSM):

    1. Go to the :guilabel:`Browser` panel and navigate to :menuselection:`XYZ Tiles --> OpenStreetMap`
    2. Drag and drop the OpenStreetMap entry to the bottom of the :guilabel:`Layers` panel

    Using your internet browser, look up the location of the University of Cape Town. Given Cape Town's unique topography, the university is in a very recognizable location. Before you return to QGIS, take note of where the university is located, and what is nearby.

  6. Ensure that the Streets layer clicked on, and that the university layer is highlighted in the :guilabel:`Layers` panel

  7. Navigate to the :menuselection:`View --> Toolbars` menu item and ensure that :guilabel:`Digitizing` is selected. You should then see a toolbar icon with a pencil on it (toggleEditing Toggle editing). This is the Toggle Editing button.

  8. Click the :guilabel:`Toggle editing` button to enter edit mode. This allows you to edit a vector layer

  9. Click the capturePoint Add Point Feature button, which should be nearby the toggleEditing Toggle editing button

  10. With the :guilabel:`Add feature` tool activated, left-click on your best estimate of the location of the University of Cape Town

  11. Supply an arbitrary integer when asked for the id

  12. Click :guilabel:`OK`

  13. Click the saveEdits Save Layer Edits button

  14. Click the :guilabel:`Toggle editing` button to stop your editing session

  15. Save the project

Find the locations that are closest to the University of Cape Town

  1. Go to the Processing Toolbox, locate the Join Attributes by Nearest algorithm (:menuselection:`Vector general --> Join Attributes by Nearest`) and execute it
  2. :guilabel:`Input layer` should be university, and :guilabel:`Input layer 2` suitable_areas
  3. Set an appropriate output location and name (Joined layer)
  4. Set the :guilabel:`Maximum nearest neighbors` to 4
  5. Ensure that checkbox :guilabel:`Open output file after running algorithm` is checked
  6. Leave the rest of the parameters with their default values
  7. Click :guilabel:`Run`

The resulting point layer will contain four features - they will all have the location of the university and its attributes, and in addition, the attributes of the nearby suitable areas (including the id), and the distance to that location.

  1. Open the attribute table of the result of the join
  2. Note the id of the four nearest suitable areas, and then close the attribute table
  3. Open the attribute table of the suitable_areas layer
  4. Build a query to select the four suitable areas closest to the university (selecting them using the id field)

This is the final answer to the research question.

For your submission, create a fully labeled layout that includes the semi-transparent hillshade layer over an appealing raster of your choice (such as the DEM or the slope raster, for example). Also include the university and the suitable_areas layer, with the four suitable areas that are closest to the university highlighted. Follow all the best practices for cartography in creating your output map.