Exercise: Security Peshawar#

🔙Back to Homepage

Click here to return to the exercise overview page for module 3

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.

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#

  1. Drag and Drop the ACLED conflict excel table ‘2024-01-01-2024-09-23-Pakistan.xlsx’ into your QGIS project

  2. 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”.

../../_images/Create_ponts_from_table.PNG

Create points from table#

  1. Get number of events per thesil

    • Load the “KP admin 3” layer.

  2. 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”.

../../_images/count_point_polygon.PNG

Count points from polygon#

  1. 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.

../../_images/Number_events_graduated.PNG

Number of conflict events per thesil#

Task 3: MPI data#

  1. 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

    ../../_images/PAK_Excel_to_CSV.png

    Convert Excel to CSV#

  2. Open QGIS and create a new project. Save the project in your project folder.

  3. 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 choose No 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.

    ../../_images/PAK_Load_CSVfile.PNG

    Load CSV file to QGIS#

To visualize the data now on the map we have to link it to existing geometries and district boundaries. To do that:

  1. 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.

  2. 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.

  3. 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.gpkg

    • Table field: admin2Pcode

    • Input layer 2: 20240605_PAK_MPI.csv

    • Table field 2: ADM2_PCOCDE

    • Choose a location to save the file as GeoPackachge and give it a meaningful name, for instance MPI_Admin2_joined.gpkg

    • Run and close.

    ../../_images/PAK_joined_MPI_csv_admin2.PNG

    Join the districts with the MPI data#

    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.

    ../../_images/PAK_joined_MPI_csv_admin2_info.PNG

    Information of not joined and linked data#

  4. 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.

  5. 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.

  6. Add OpenStreetMap as a baselayer for better orientation.

../../_images/PAK_visualized_MPI.PNG

Visualized MPI data on district level#