Exercise: Security Peshawar#
đBack to Homepage
Aim of the exercise:
Type of trainings exercise:
This exercise can be used in online and presence training.
These skills are relevant for
QGIS Essentials
Working with multiple layers
Conduct spatial queries
Creation of geodata
Estimated time demand for the exercise.
The exercise takes around 3 hours to complete, depending on the number of participants and their familiarity with computer systems.
Relevant wiki articles
Instructions for the trainers#
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? 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.
Available Data#
Download all datasets here and save the folder on your computer and unzip the file.
Dataset name |
Original title |
Publisher |
Download from |
---|---|---|---|
2024-01-01-2024-09-23-Pakistan.xlsx |
Conflict data for Pakistan 01/2024-09/2024 |
ACLAD |
HDX |
PAK_KP_admin_3.gpkg |
Administrative Boundaries level 3 of KP |
UN OCHA |
HDX |
Pak_adm2_Khyber Pakhtunkhwa.gpkg |
Administrative Boundaries level 1 of KP |
UN OCHA |
HDX |
20240605_PAK_MPI.xlsx |
Pakistan Multi Poverty Index (MPI) |
Pakistan Bureau of Statistics |
Pakistan Bureau of Statistics |
AOI_Peshawar.gpkg |
Area of Interest (AOI) around Peshawar |
Task 2: Load Excel File containing conflict data into QGIS#
Drag and Drop the ACLED conflict excel table â2024-01-01-2024-09-23-Pakistan.xlsxâ into your QGIS project
Navigate in the Processing Toolbox to the Tool âCreate points layer from tableâ.
Choose as âX Fieldâ âlongitudeâ and as âY Fieldâ âlatitudeâ.
Under âPoints from Tableâ , click on the three dots, choose âSave to GeoPackageâ and navigate to you temp folder. Save the layer with the name âPak_Conflict_points_2024â.
Get number of events per thesil
Load the âKP admin 3â layer.
We are now interested to know the number of conflict incidents per thesil. For this:
Go to the Processing Toolbox and search for the Tool âCount points in polygonâ. Choose âKP_adm3â layer as Polygon input and the âPak_Conflict_points_2024â layer as Points input
Under
Count
save your new layer under âPak_num_events_adm3â.
Open the attribute of your âPak_num_events_adm3â layer and scroll to the right. You will find a column with the name âNUMPOINTSâ. Here you find the number of events per thesil.
Right-click on the layer and navigate to âPropertiesâ â> âSymbologyâ. On the top change Single Symbol to âGraduatedâ.
In the âValueâ field choose âNUMPOINTSâ.
Then below click on âClassifyâ
You can adjust the Mode and the number of classes if wanted. Also you can choose your preferred color ramp.You can play around a bit here.
Click âApplyâ and then âOKâ
Your result could look similar to this.
Task 3: MPI data#
Open the excel file and export it as CSV UTF-8:
Click on
File
->Save As
Chosse an output folder, where it will be saved (the
data
>temp
folder is recommended here) and give the file a meaningful name, for instance 20240605_PAK_MPI.Choose the option CSV UTF-8 (Comma delimited) (*.csv) and
Save
Open QGIS and create a new project. Save the project in your project folder.
Add the 20240605_PAK_MPI.csv file to QGIS by:
Click on the
Layer
tab ->Add Layer
>Add Delimited Text
Browse for your 20240605_PAK_MPI.csv file.
Choose the correct
File Fromat
:Custom delimters
->Semicolon
Go to the tab
Geometry Definition
and chooseNo geometry
. We donât have a column with coordinates or geoemtry information, but only the admin2 name and P-Code.Add layer and close the window.
To visualize the data now on the map we have to link it to existing geometries and district boundaries. To do that:
Open the attribute table of the attribute table and detect the column which contains the information you want to use to join the data with the location. E.g. City name, district name, or best the P-Code. In our case it is
ADM2_PCODE
.Hint: Each administrative level and area contains a worldwide unique code number. This helps to determine the exact administrative boundary without misspelling the name of the area.
We now need an admin layer with an column containing the exact same information as the column of our CSV file. This is needed to link the information provided in the CSV to the district areas.
Load the layer Pak_adm2_Khyber Pakhtunkhwa.gpkg via drag and drop to QGIS.
To link the two layers, open the Toolbox and search for the tool Join attributes by field value. Open it.
Input layer
: Pak_adm2_Khyber Pakhtunkhwa.gpkgTable field
: admin2PcodeInput layer 2
: 20240605_PAK_MPI.csvTable field 2
: ADM2_PCOCDEChoose a location to save the file as GeoPackachge and give it a meaningful name, for instance MPI_Admin2_joined.gpkg
Run
and close.
Info: You can see that not all areas are visible. Since we donât have data for all districts, only the districts were linked with the csv on which we have MPI data.
Visualize MPI_Admin2_joined.gpkg file: We have a new file, showing the district boundaries, but having the MPI information in the attribute table. The MPI value per district we now want to visualize.
Open the
Symbology
window of the file MPI_Admin2_joined.gpkg.Decide which column you want to visualize. For instance the values of the year 2014 in the column A_2014_15.
Choose
Graduate
visualization.Choose
Value
A_2014_15.Click
Classify
.Choose Mode
Pretty Breaks
.Click okay and close the window.
Visualize Pak_adm2_Khyber Pakhtunkhwa.gpkg layer for districts we donât have MPI data on.
Open the
Symbology
window of the file Pak_adm2_Khyber Pakhtunkhwa.gpkg.Change the color, maybe to dark grey, so we can differentiate between the districts we have and donât have MPI data for.
Add OpenStreetMap as a baselayer for better orientation.