QGIS Basic Exercise SRCS#

CSV in QGIS#

Aim of exercise#

In this task, we will load a CSV file in QGIS and do some analysis.

Task 1: Load data in QGIS#

  1. Open the folder “Exercise 2”. Go into the “data” folder and copy all data from the “input” folder into the “temp” folder

  2. To load the file “Water_sources.csv” into QGIS click on Layer -> Add layer -> Open Delimited Text Layer. Next to File name click on the three points and navigate to your “temp” folder. Her select the file “water_sources.csv”.

  3. Use the setings like in the image below.

../../_images/add_csv.png
  1. Click Add

  2. Load the file “district_pop_som.shp” into QGIS

Tip

To directly load .csv or EXCEL data into QGIS, the datasets need to have columns containing geometry in the form of latitude (Y-field) and longitude (X-field).

Task 2: Counting water sources per district#

  1. In the Toolbox-> Search for Join attribute by location (summary)

    • Tip: If the Toolbox is not opne click Processing-> Toolbox

  2. Input Layer: Select your “district_pop_som” layer

  3. Input Layer 2: Select “Water_sources”

  4. Geometric predicate: Select “Intersection”

  5. Field to summarise: Select “fid”

  6. Summaries to calculate: Chose only the option “count”

  7. Under Join Layer click on the three points -> Save to File and navigate to your “temp” folder. Give the output the name “district_watersources” and click Save

  8. Click Run

../../_images/Join_layer_summary_watersources.png
Video: impoering .csv

Task 3: Calculating water sources per 10.000 people#

  1. Open the Attribute Table of “district_watersources”

  2. Click on Field Calculator to open the field calculator

  3. Check Create new field

  4. Output field name: Name the new column “Watersources_pop”

  5. Result field type: Decimal number (real)

  6. Add the code into the Expression field

( "fid_count"  /  "districtpo"  )  * 10000
../../_images/watersources_per_pop_field_calculator.png
  1. Click ok

  2. Save the new column by clicking on in the attribute table and end the editing mode by clicking on

  3. Sorte the new column “Watersources_pop” and finde out wich districts have the highest and lowest number of water sources per 10.000 people

QGIS Intro#

Aim of exercise#

The goal of the exercise is to get to know the basic functionality of QGIS and how to handle geodata.

Task 1: Folder and data structure#

  1. Save the folder Exercise_1 on your computer. Check out the folder structure in the Exercise_1 folder.
    The standard folder structure used makes certain that you never lose any data. You can find more infos about the standard folder structure we recommend here.

  2. Please save your QGIS project in the “project” folder.

  3. Copy the data from the “input” folder into the “temp” folder. During this exercise we will manipulate the input data, that is why we do not work with the original data in the “input” folder.

Tip

Intermediate results should also be saved in the “temp” folder. The final results should be saved in the “output” folder and your final maps in the “results” folder.

Task 2: Data import into QGIS#

  1. Open QGIS and create a new project by clicking on Project -> New Project (Wiki).

  2. To give the project a name click on Project -> Save As. Navigate to “Exercise_1” and open the “project” folder. Give your project the name “Exercise_1” and click on Save. Now you should see the name of your project in the upper left corner of your QGIS.

  3. Open the file “Somaliland_country.shp” in QGIS. Click on the Layer Tab in the upper left corner -> Vector. Select “Somaliland_country.shp”. Click Add (Wiki Import Vector layer)

Video: Import Vector data

  1. Open the file Somaliand_District_pop.gpkg in QGIS. Use the drag-and-drop method. Click on the file and pull the file directly into your Layers window.

Video: Import data by drag and dop

  1. Open the files “Somalialand_District_pop.gpkg” and Somaliland_airports.gpkg with either drag and drop or via Layer -> Vector.

  2. Save your project by clicking on the Save Project button (small disc in the upper left corner).

Task 3: Interface#

  1. Layers List / Browser Panel: The layers list shows all layers/files that are loaded in the project. You can show/hide layers and set other properties.

  2. Toolsbars: Toolbars are shortcuts to execute frequently used commands. For example, there are special toolbars for vector and raster files, but also general ones for saving your project, etc. The toolbar contains, among other things, a list of all the commands you can use. The toolbar also contains the toolbox, which is used later in many of the wiki videos.

  1. Map View: The map view is the central component of every GIS programme. This is where the geodata are displayed. The map view has a projection which does not always have to correspond to the projection of the layers.

  2. Status bar: In the status bar you will find central information about the current map view. Here you can set the projection of the map view and the scale. You can read the coordinates of the mouse pointer and thus quickly find out the coordinates of points on the map. You can rotate your map view, e.g. if you want to create a map facing south.

  3. Side Toolbar. You may see a side toolbar. This is another way to easily open vector and raster files in QGIS.

  4. Locator bar. Here you can search for tools and layers. If you don’t know where to find a tool, you can try here.

Task 4: Layer concept#

In this task, we familiarise ourselves with the layer window (Layer List). The concept means that a map in GIS is always a combination of multiple layers. We can combine the layers in many different ways and thus get different results.

You can find more infos in the Wiki Layer concept.

  1. Switch off the “Somalia_country” layer by removing the check on the layer panel (Wiki).

Video: Show and hide layers

Video:
  1. Change the hierarchy of your layers so that “Somalia_airports” is at the top, followed by “Somalia_District_pop”. Move the layer up and down in the Layer panel by drag-and-drop Wiki.

Video: Import data by drag-and-drop

  1. Move the “Somalia_country” layer to the top and switch it on. What happens?

  2. Change the name of the layer “Somalia_airports” to Airports by right click on your layer –> Rename Layer

Video: Change Layer Name

  1. To the properties of a layer right click on your layer -> Properies -> Information.

    1. When was the layer “Somaliland_district_pop” last modified?

    2. How many features does the airport layer have?

    3. What geometry does the Somalia_country layer have?

Tip

If you have “lost” your layer, right click on your layer -> Zoom to layer(s)

Wiki Video

Task 5: Attribute tables#

The attribute table, a core component of Geographic Information Systems (GIS), organizes and presents detailed information about features in a selected layer. Each row in the table represents a feature, while columns store specific attributes. This table facilitates searching, selection, sorting, filtering, and editing of features.

Example of an attribute table

Example of an attribute table

__Wiki Attribute Table

  1. Open the attribute table of “Somaliland_district_pop”. Right-click on “Somaliland_district_pop” –> Open Attribute Table (Wiki)

Video: Open attribute Table

  1. Sort by “Population” by clicking on the column header.

  2. In the attribute table select the feature “Berbera” by clicking on the left edge of the row.

Video: Select features in Attribute Table

  1. To select more features press Ctrl and click on the features.

  2. To only see selected features click in the down left corner of the attribute table on the drop-down menu and select Show selected features. To show again all features click on Show all features.

  3. To only show unselect features and click on in the attribute table.

  4. To unselect all features click on in the attribute table

Video: Unselect features

  1. To zoom to one feature right click on your feature –> Zoom To Feature

Task 6: Basic Data visualization#

Depending on the use case and type of geodata at your disposal, there are multiple ways to visualise geodata in a comprehensive format:

  • You can change the ‘styling’ and color of the data

  • You can add textlabels

All the styling in QGIS happens in Symbology

  1. To open the symbology window of the “Somaliland_country” layer right click on the Somaliland_country layer -> properties. A new window will open up with a vertical tab section on the left. Navigate to the symbology tab.

Video: Opening the styling panel

  1. Change the colour of the layer fill by selecting a style for the drop-down menu.

  2. To change the colour of the borders of the “Somaliland_country” layer by clicking on Simple fill in the symbology window and change the colour in the Stroke Colour drop-down menu.

  3. Adjust the thickness of the borders under Stroke width

  4. To only show the boarders of Somaliland click on Simple Fill -> Fill Colour -> Transparent Fill

Video: Only display the outlines of polygons

  1. Add a OpenStreetMap base map by clicking on Layer in the to left corner of QGIS -> Add Layer -> Add XYZ layer... -> Select the OpenStreetMap

Video: Adding basemap

Task 7: Clipping and Extract by location#

  1. Import the file Somalia_health_facilities_WHO.gpkg in QGIS.

Video: Import data by drag and drop

  1. The layer Somalia_health_facilities_WHO includes health facilities in Somaliland and Somalia. We only want to use the facilities in Somaliland. To cut the layer to the size of Somaliland we will use the tool __clip. Open the Porcessing Toolbox by cliking on Processing -> search for “Clip”

Video: Open Processing toolbox

  1. In the window of the Clip tool…

    1. Input Layer: “Somalia_health_facilities_OSM”

    2. Overlay Layer: “Somaliland_country”

    3. Clipped: Click on the three points -> Save to File -> search for your “temp” folder -> give the result layer the name “Somaliland_health_facilities” and click on Save

    4. Click Run

../../_images/QGIS_basics_Fig11.png
Video: Clip example

  1. Now you should have a new point layer with all health facilities in Somaliland. Delete the old “Somalia_health_facilities_WHO” layer by right-click on the layer -> Remove layer

Task 8: Data visualization- Categorized classification of Points#

Categorized classification in QGIS groups spatial data into distinct categories based on specific attributes. This classification enhances the organization and interpretation of geospatial information for clearer insights.

  1. Open the attribute table of “Somaliland_health_facilities_OSM” by right clicking on “Somaliland_health_facilities_OSM” -> Open Attribute Table

  2. Check out the column “Facility t”. This column has the data on the type of the health facility. As you can see there are not just hospitals but many different typs of facilities like Health posts.

  3. To categorise all facilities by type on the map, open the symbology window. Right-click on the “Somaliland_health_facilities_OSM” layer -> Properties-> symbology

  4. Click on Categorized

  5. Value: “Facility t”. Further down the window click on Classify. Now you should see all unique values or attributes of the selected “Facility t” column.

  6. We only want to see the hospitals, so uncheck Maternal & Child Health Centre, Health Post and Health Center.

  7. Click Apply

../../_images/QGIS_basics_Fig12.png
Video: Categorized classification Example

  1. To use a prearranged style for the hospitals go to the Symbology window. In the down left corner click on Style -> Load Style

  2. In the new window click on the three points . Navigate to the “Project” folder -> “Style” folder and select the file “Hospital_style_training.qml. (Wiki)

  3. Click Open. Then click on Load Style

  4. Back in the “Layer Properties” Window click Apply and OK

Figure