Skip to content

Commit

Permalink
Merge pull request #131 from GIScience/dev
Browse files Browse the repository at this point in the history
main update
  • Loading branch information
enauj authored Nov 7, 2024
2 parents c8cb56b + 716e1d6 commit 6311180
Show file tree
Hide file tree
Showing 16 changed files with 782 additions and 344 deletions.
363 changes: 283 additions & 80 deletions content/Modul_4/en_qgis_map_design_I.md

Large diffs are not rendered by default.

263 changes: 206 additions & 57 deletions content/Modul_4/en_qgis_map_design_I_ex1.md

Large diffs are not rendered by default.

263 changes: 57 additions & 206 deletions content/Modul_4/en_qgis_map_design_I_ex2.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/Modul_4/en_qgis_modul_4_exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ These exercises touch on all the content of Module 4.

| Exercise| Description |Focus Group|Estimated time|
| :-------------------- | :----------------- |:----------------- |:----------------- |
| __[Exercise 1: Creating a Map of Ghana](/content/Modul_4/en_qgis_map_design_I_ex2.md)__ | The aim of this exercise is to create an overview map of Ghana with its subdistricts, main roads, settlements, and hospitals. Such information is very useful for humanitarian work. The first part of the exercise will cover the symbolisation of the data layers. The second part will focus on the design of the print layout. | QGIS Intermediates | 5 hours |
| __[Exercise 1: Creating a Map of Ghana](/content/Modul_4/en_qgis_map_design_I_ex1.md)__ | The aim of this exercise is to create an overview map of Ghana with its subdistricts, main roads, settlements, and hospitals. Such information is very useful for humanitarian work. The first part of the exercise will cover the symbolisation of the data layers. The second part will focus on the design of the print layout. | QGIS Intermediates | 5 hours |
| __[Exercise 2: Creating a Map of Pakistan](/content/Modul_4/en_qgis_map_design_I_ex4.md)__ | The aim of this exercise is to create a a map of the flood situation in Larkana, Pakistan. Such information is very useful for humanitarian work and especially flood response. The first part of the exercise will cover the symbolisation of the data layers. The second part will focus on the design of the print layout. | QGIS Intermediates | 3 hours |


Expand Down
40 changes: 40 additions & 0 deletions content/Modul_4/en_qgis_symbology_raster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Symbology for raster data

As we have already learned, raster data are basically a grid of pixels with different (numerical) values. As such, you can't style the shape, fill or outline of raster data. Raster data is visualized by assigning a colour ramp to the pixel value. QGIS offers several options to visualise raster data. For example, you can create a hillshade with digital elevation model (DEM).

### Assigning a colour gradient to raster data

To assign a colour gradient for raster data, you need to:

1. Open the `styling panel` for the raster layer
2. Navigate to the `Symbology tab`
3. By default, the colour scheme is set to Singleband Gray (if you only have one colour band in the data set). Click on `Singleband Gray` and switch to `Singleband Pseudocolour`
4. Click on __the arrow to the right of the colour ramp__. Here you can choose a pre-made colour ramp
5. You can modify the colour ramp by __clicking on the colour ramp__.

``` {figure} ../../fig/en_30.30.2_raster_data_colour_gradient.png
---
name: raster data colour gradient
width: 600px
---
Colour Ramp Selector
```

In the colour ramp selector, you can adjust each colour step. On the bottom, you can see a plot for the Hue, __Saturation__, __Lightness__ and __Opacity__. The last three in particular are useful to understand how your colour ramp will appear. Gradients from light to dark are easier to read: Check if the plot for the __Lightness__ has a more or less linear plot.

#### Styling a digital elevation model

Elevation data sets are frequently used to communicate the terrain on a map. By default, an elevation model will be displayed with a gray colour ramp. However, if you don't need the to know the elevation at certain points, you can choose to display the __hillshade__ of the terrain. Hillshading will simulate the shadow of the terrain as if it would be exposed to a light source. In this example, we will use the elevation raster data (.tiff) of Algeria from the Humanitarian Data Exchange platform (humdata.org) To achieve this,

1. Open the `symbology` tab
2. Click on `Render type` and select `Hillshade`. You will have an option to select the direction of the light. Conventionally, the light source is positioned in the North-West, so we can keep the default settings. In some cases with rough terrain, it can be useful to make the hillshade __Multidirectional__.
3. The hillshade will be very dark and cover most of the map. We need to make it lighter...

<!--ADD: Video-->

### Inverting the colour ramp

In some cases, the colour ramp should be inverted to make it easier to read the map:

1. Click on the __arrow next to the Colour ramp__ to open the dropdown menu.
2. Click on `Invert Colour Ramp`.
1 change: 1 addition & 0 deletions content/Modul_5/en_qgis_modul_5_exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ These exercises touch on all the content of module 5.
| __[Exercise 2: Disaster impact in different regions of Senegal](/content/Modul_5/en_qgis_non_spatial_tools_ex1.md)__ | Become familiar with different types of non-spatial analysis and geoprocessing tools. Understand the process of discovering relationships and connections between features in spatial data. | Data analysis | 3 hours |
| __[Exercise 3: Trigger & Intervention Map for Forecast-based-Action](/content/Modul_5/en_qgis_modul_5_ex2.md)__ | This exercise is based on the monitoring and triggering process used by the Somalia Red Cresent Society (SRCS) in the framework of a drought Early Action Protocol (EAP). In this exercise, you will build a simplified version of the monitoring and trigger mechanism for the FEWSNET projection pillar. | Data analysis, Early Action Protocol, Monitoring & Triggering | 6 hours |
| __[Exercise 4: Security Peshawar](/content/Modul_5/en_qgis_modul_5_ex3.md)__ | | Data analysis | 3 hours |
| __[Exercise 5: Assess G2P Disbursement](/content/Modul_5/en_qgis_module_5_ex4.md)__ | The exercise teaches how to aggregate data on administrative levels and subsequently join the aggregated data with a polygon dataset. | Data analysis and creating reports | 60 minutes |



Expand Down
194 changes: 194 additions & 0 deletions content/Modul_5/en_qgis_module_5_ex4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Exercise 5: Aggregate and Assess the Cash Programs in Pakistan

## Characteristics of the exercise

:::{card}
__Aim of the exercise:__
^^^
The aim of this exercise is to introduce a workflow that combines both spatial and non-spatial processing. A common step is to aggregate data on administrative scales such as adm2 or adm3. This exercise will teach you how to aggregate information about cash transfers on administrative levels and then join the statistics with a polygon data for the administrative boundaries.

:::

::::{grid} 2
:::{grid-item-card}
__Type of trainings exercise:__
^^^

- This exercise can be used in online and presence training.
- It can be done as a follow-along exercise or individually as a self-study.

:::

:::{grid-item-card}
__These skills are relevant for__
^^^
- Aggregating and analysing data
- Creating situational reports

:::
::::

::::{grid} 2
:::{grid-item-card}
__Estimated time demand for the exercise__
^^^
60 minutes

:::

:::{grid-item-card}
__Relevant Wiki Articles__
^^^

* [Geodata Import in QGIS](/content/Wiki/en_qgis_import_geodata_wiki.md)
* [Statistics by Categories](/content/Modul_5/en_qgis_non_spatial_tools.md)
* [Non-Spatial Join](/content/Wiki/en_qgis_joins_wiki.md)

:::

::::

## Instructions for the trainers

:::{dropdown} __Trainers Corner__

### Prepare the training

- Take the time to familiarise yourself with the exercise and the provided material.
- Prepare a white-board. It can be either a physical whiteboard, a flip-chart, or a digital whiteboard (e.g. Miro board) where the participants can add their findings and questions.
- Before starting the exercise, make sure everybody has installed QGIS and has downloaded __and unzipped__ the data folder.
- Check out [How to do trainings?](/content/Trainers_corner/en_how_to_training.md) for some general tips on training conduction

### Conduct the training

__Introduction:__

- Introduce the idea and aim of the exercise.
- Provide the download link and make sure everybody has unzipped the folder before beginning the tasks.

__Follow-along:__

- Show and explain each step yourself at least twice and slow enough so everybody can see what you are doing, and follow along in their own QGIS-project.
- Make sure that everybody is following along and doing the steps themselves by periodically asking if anybody needs help or if everybody is still following.
- Be open and patient to every question or problem that might come up. Your participants are essentially multitasking by paying attention to your instructions and orienting themselves in their own QGIS-project.

__Wrap up:__

- Leave time for any issues or questions concerning the tasks at the end of the exercise.
- Leave some time for open questions.

:::

## Instructions

### Background

### Step-by-step instructions

:::{card}
:class-card: sd-text-justify sd-rounded-3 sd-border-2
:link:

Click here to download the datasets for this exercise.

:::

:::{card}
__Available Data:__
^^^

- `G2P_disbursement_report_cleaned.csv` - Datatable with cash transactions. This dataset has been cleaned and all information has been removed.
- `pak_admbnda_adm2_wfp_20220909` - Administrative boundaries on adm2 level (districts).
:::

::::{margin}
```{tip}
To load the CSV-file, navigate to `Layer` > `Add Layer` > `Add delimited text layer`.
```
::::

1. Unzip the exercise data and create a new QGIS-project.
2. Load the data into your QGIS-project.
3. Let's familiarise ourselves with the data. Open the attribute table of each layer and see what kind of information is stored in the datasets.

```{note}
We want to aggregate the information about money transactions on adm3- or adm2-level. Can you identify which column in the `G2P_disbursement_report_cleaned`-layer corresponds to adm2 and adm3?
:::{dropdown} Solution
By comparing the values in the column `admin2_EN` from the `pak_admbnda_adm2_wfp_20220909`-layer, we can see that the column `var_attr_03` corresponds to the admin2-level in the `G2P_disbursement_report_cleaned`-layer. By sorting the layers alphabetically, it is easier to find matching values in both attribute tables.
:::
```

#### Step 1: Aggregating the amount of transferred money on admin2

3. In the processing toolbox, search for the tool `Aggregate` under `Vector Geometry`. <kbd>Double-Click</kbd> on it. A new window will open (see {numref}`aggregate_tool`).

```{figure} /fig/en_3.36_aggregate.png
---
name: aggregate_tool
width: 600 px
---
The Aggregate-tool in QGIS 3.36
```

4. In the "Aggregate"-window,
1. Select the `G2P_disbursement_report_cleaned`-layer as input layer.
2. `Group by Expression` is where we select which column we want to have grouped (or selected as category). We want to identify the amount of money transferred to each district (admin2-level), so we need to select the corresponding column. In our case, this is the column `var_attr_03`.
3. This box is where we select how the tool aggregates the different columns:
- We want to calculate the `Sum` for the column "Amount".
- For the column "var attr 03" we want to select `Concatenate_unique`. This returns all unique strings from a field.
- The other columns can be set to `concatenate_unique`
4. Click `Run`. A new layer called "Aggregated" will appear in the layers-panel. Close the "Aggregate"-window.


```{figure} /fig/en_3.36_aggregate_settings.png
---
name: aggregate_settings
width: 650 px
---
Adjust the aggregation function for the relevant columns. Pay attention that the `Type` for the amount is set to "Integer". If you have imported the table correctly into QGIS, this should be set automatically.
```
```{admonition}
:type: note
If the `Type` for the amount column is set to "Text (string)", this means that QGIS reads the data format for this column as being a string value. QGIS can't perform mathematic operations on string values because they are being read as non-numeric data. Make sure to import the layer through the `Add delimited text layer`-dialogue (`Layer` > `Add Layer` > `Add delimited text layer...`) and make sure the `Type` for the column "Amount" is set to Integer.
```
5. Let's take a look at the new layer by opening the attribute table. If you have done everything correctly, the table should look like {numref}`aggregate_results`. We can see on row for each distinct value in the `var attr 03` column (Gwardar, Jamshoro, Dadu, Kambar Shahdadkot, Shiparpur). In the column `Amount` we see the sum of all the individual transfers. In the other columns, we can see a string with the different values of the original table separated by commas (e.g. the different admin3-units, Thesils, under the column `var attr 04`).
```{figure} /fig/en_aggregate_results.png
---
name: aggregate_results
width: 650 px
---
The aggregated data from `G2P_disbursement_report_cleaned`
```
#### Step 2: Joining the aggregated data with administrative boundaries
In this step, we want to add the aggregated information we gained from the CSV file to the administrative boundaries. We need to join the aggregated table with the `pak_admbnda_adm2_wfp_20220909`-layer.
1. In the processing toolbox, search for `Join attributes by field value`. <kbd>Double click</kbd> on it. A new window will open.
```{figure} /fig/en_3.36_join_by_attr.png
---
name: join_by_attr
width: 700 px
---
The Join attributes by field value dialogue box in QGIS 3.36.
```
1. The input layer should be `pak_admbnda_adm2_wfp_20220909`-layer. This will be the layer that will receive additional information. The geometries of the input layer will be preserved. The `Table field` should be set to "ADM2_EN". These are english names for the admin2-level.
2. The second input layer should be the `Aggregated` layer from the previous step. `Table field 2` should also be the english names for the administrative boundaries. In our case, the corresponding column is "var attr 03". Under `Layer 2 fields to copy`, only select `amount` as we are not interested in the other values.
2. Click `Run`. A new layer `Joined Layer` will appear in the layer-panel.
3. Close the joining dialogue window and investigate the new layer by opening it's attribute table. Scroll the right to find the new column "amount" that has been joined.
4. Notice how most of the rows have `NULL` as their value in this column? This is because the aggregated table only has 5 distinct districts (adm2) that received money. You can sort the table by clicking on the column header.
Congratulations, we have succesfully joined a CSV-file with a polygon layer!
<!--ADD: Optional steps to aggregate based on gender and status to create a map with additional information?-->
Binary file added fig/choropleth_hum_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/choropleth_intro_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/en_3.36_aggregate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/en_3.36_aggregate_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/en_3.36_join_by_attr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/en_aggregate_results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/en_complex_bivariate_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/proportional_circles_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/proportional_circles_example_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6311180

Please sign in to comment.