-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from GIScience/dev
main update
- Loading branch information
Showing
16 changed files
with
782 additions
and
344 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?--> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.