Tutorial: Process Groundwater Data in QGIS

Site: OpenCourseWare for GIS
Course: GIS training for Hydrogeological Applications
Book: Tutorial: Process Groundwater Data in QGIS
Printed by: Guest user
Date: Wednesday, 8 May 2024, 6:45 AM

Description

1. Introduction

Now we have collected data from different internet resources we can further process the data for our groundwater GIS project, which will be in the Shire aquifer in Malawi.

After this tutorial you're able to:

  • Reproject layers
  • Select features by expression
  • Export selected features
  • Create buffers
  • Dissolve features
  • Intersect layers
  • Clip layers
  • Use the Point Sampling Tool
  • Join attributes and make them permanent

2. Theory: vector geoprocessing tools

Here's a useful video with theory on vector geoprocessing tools that we'll use in this tutorial:

3. Reproject layers

We'll start where we ended with the previous tutorial.

1. Start QGIS

2. In the main menu go to Project | Open From | GeoPackage...

3. In the Load project from GeoPackage use the button to browse to the new folder with the copy of the Malawi_GIS_data.gpkg file and choose the Malawi_Groundwater project. Click OK to open.


The Geology and Hydrogeology layers are still in a Geographic Coordinate System (GCS) with latitude/longitude coordinates in degrees (EPSG: 4326). We'll first reproject these layers to match the UTM Zone 36S / WGS-84 projection (EPSG: 32736) that we're using in this project.

4. In the Layers panel click right on the Geology layer and choose Export | Save Features As...

5. In the Save Vector Layer as... dialogue choose GeoPackage as Format, use the existing Malawi_GIS_data.gpkg and type Geology UTM as Layer name. Change the CRS to the Project CRS (EPSG: 32736).

6. Click OK.

The Malawi_GIS_data Geology UTM layer has now been added to the Layers panel, but it doesn't have the styling. We can copy the styling from the original Geology layer.

7. In the Layers panel click right on the Geology layer and choose Styles | Copy Style | All Style Categories.


8. Then in the Layers panel click right on the Malawi_GIS_data Geology UTM layer and choose Styles | Paste Style | All Style Categories.

You might need to rearrange your layers in the Layers panel to see the results.

9. Repeat steps 4 to 8 for the Hydrogeology layer and name the new layer in the GeoPackage Hydrogeology UTM.


4. Define the study area

In this section we're going to define the study area, which is the Shire Valley Alluvial Aquifer.

We can find this transboundary aquifer in the aquifers layer.

In the next subsection we're going to select the Shire Valley Alluvial Aquifer from the aquifers layer. Then we're going to export the selected feature to a new layer in our GeoPackage.

4.1. Select a feature by expression

The first step is to select the Shire Valley Alluvial Aquifer from the aquifers layer.

1. Click right on the aquifers layer in the Layers panel and choose Open Attribute Table.

2. Click the Select features using an expression button .

3. In the Select by Expression dialogue expand in the middle of the window Fields and Values and double click on AQ_NAME. This will add "AQ_NAME" to the expression on the left side of the window. Then click to add = to the expression. Now on the right side click the button and search the list that appears for Shire Valley Alluvial Aquifer. Double click on Shire Valley Alluvial Aquifer to add it to the expression, which is now:

"AQ_NAME" = 'Shire Valley Alluvial Aquifer"

Select aquifer expression

This means: select from the field AQ_NAME (field names are in double quotes) the Shire Valley Alluvial Aquifer feature. Features are in single quotes.

4. Click to select the feature based on this expression.

5. Click Close to close the dialogue.

6. Close the attribute table.

In the map canvas you can now see the selected aquifer with a yellow boundary. Selections are yellow by default in QGIS.

Now we're going to export the Shire Valley Alluvial Aquifer.


4.2. Export selected feature(s)

Now we have selected the aquifer of our study area we can export the feature to a new layer in our GeoPackage.

1. Click right on the aquifers layer in the Layers panel and choose Export | Save Selected Features As...

2. In the Save Vector Layer as... dialogue choose GeoPackage as Format. Choose our existing GeoPackage Malawi_GIS_data.gpkg as File name. Give it the Layer name Shire Valley Alluvial Aquifer. Check that the CRS is EPSG: 32736.

3. Click OK.

The Malawi_GIS_data Shire Valley Alluvial Aquifer layer is now added to the project.

Shire aquifer added as layer

In the next subsection we'll create a buffer around the aquifer boundary to extend the study area a bit to account for boundary effects.


4.3. Create a buffer around the aquifer

To account for boundary effects it is advised to create a buffer around the aquifer of our study area.

1. In the main menu go to Vector | Geoprocessing Tools | Buffer...

2. In the Buffer dialogue choose the Malawi_GIS_data Shire Valley Alluvial Aquifer as Input layer. Set the Distance to 10 kilometers. Keep the other settings as default and save the layer to the Malawi_GIS_data.gpkg with the layer name Shire buffer 10km.

Buffer dialogue

3. Click Run. Click Close to close the dialogue after processing.

Now the Shire buffer 10km layer is visible in the map canvas.

Because we're only considering the aquifer that covers Malawi, we're going to clip the Shire buffer 10km layer to the country boundary in the next subsection.


4.4. Create a country boundary by dissolving features

In this subsection we're going to clip the Shire buffer 10km layer to the boundary of Malawi.

We could download a country boundary from for example the Natural Earth dataset. Here, however, we can use the Geology UTM or Hydrogeology UTM layer which cover only Malawi. The advantage of this method is that the boundaries will better match the layers.

We can create the country boundary by dissolving all features in the Geology layer (similar for the Hydrogeology layer, but here we'll explain it for the Geology layer).

1. In the main menu go to Vector | Geoprocessing Tools | Dissolve...

2. In the Dissolve dialogue choose Malawi_GIS_data Geology UTM as Input layer and save the Dissolved layer to the Malawi_GIS_data.gpkg with the name Malawi country boundary. Keep the other settings as default so we dissolve all fields in the layer.

Dissolve to Malawi country boundary

3. Click Run. Click Close after processing.

Now the Malawi country boundary layer appears in the map canvas.

Malawi country boundary

The next step is to clip the Shire buffer 10km layer to the Malawi country boundary.

4.5. Intersect the country boundary with the buffered transboundary aquifer

To obtain the study area we need to need to retain the area of the Shire buffer 10km which falls within the Malawi country boundary.

We can do that by using an intersection.

1. In the main menu go to Vector | Geoprocessing Tools | Intersection.

2. In the Intersection dialogue choose the Shire buffer 10km layer as Input layer and the Malawi country boundary as Overlay layer. Keep the other settings as default and save the Intersection output to the Malawi_GIS_data.gpkg GeoPackage with the name Shire study area.

Intersection dialogue

3. Click Run. Click Close to close the dialogue after processing.

No we have derived the study area and we can clip the other layers to the boundaries of the study area. We'll do that in the next section.

Shire study area


5. Clip layers to study area boundaries

Now we have the study area boundary, we can clip all layers to those boundaries to further prepare our dataset.

We'll do that first for the Malawi_GIS_data Geology UTM layer.

1. In the main menu go to Vector | Geoprocessing Tools | Clip...

2. In the Clip dialogue choose Malawi_GIS_data Geology UTM as Input layer and Shire study area as Overlay layer. Save the Clipped layer to the Malawi_GIS_data.gpkg GeoPackage with the name Shire Geology.

Clip dialogue

3. Click Run. Click Close to close the dialogue after processing.

4. Copy the style from the Malawi_GIS_data Geology UTM layer to the Shire Geology layer as you have learned before in Section 2.

5. Uncheck layers that obstruct the result.

You'll now see the Geology in the study area.

Geology in the study area

6. Repeat steps 1 to 5 for the Malawi_GIS_data Hydrogeology UTM layer and name the output Shire Hydrogeology.

The result should look like the figure below.

Hydrogeology of the study area

This also works for the point vector layers.

7. Repeat steps 1 to 5 for ramsar_sites_malawi an save the output to Shire Ramsar sites.

8. Repeat steps 1 to 5 for groundwater_monitoring_wells an save the output to Shire groundwater monitoring wells.

The result should look like this with some shuffeling of layers.

Clipped point vector layers

9. Remove the layers that we don't need anymore from the Layers panel. We should only keep the following layers for the study area:

10. Save the project under a new name in the Malawi_GIS_data.gpkg GeoPackage. Name it Shire_groundwater. Remember to choose from the main menu Project | Save To | GeoPackage...

In the next section we're add the geology and hydrogeology attributes to the monitoring wells.


6. Add attributes from other layers to point layers

For our Shire groundwater study it would be useful to add the geology and hydrogeology attributes to the Shire groundwater monitoring wells layer.

For this purpose we need to install the Point sampling tool plugin. Note that you need an internet connection to install the plugin.

1. In the main menu go to Plugins | Manage and Install Plugins...

2. In the Plugins dialogue search for the Point sampling tool and click Install Plugin.

Install Point sampling tool

3. Click the button in the toolbar to open the Point Sampling Tool dialogue.

4. In the Point Sampling Tool dialogue at the General tab choose the Shire groundwater monitoring wells as Layer containing sampling points. Choose all the fields from the Shire groundwater monitoring wells and the MaIHGComb and MaGLG fields from either the Shire Geology or the Shire Shire Hydrogeology layers (the have the same attribute table, but only differ in styling). Note that these layers need to be checked in the Layers panel in order to show up in this list. Save the Output point vector layer to an ESRI Shapefile, because this tool can't add it to an existing GeoPackage. Name it wells_hydro_geology.shp.

5. Now click the Fields tab. There you can change the name of the output fields if necessary. Here we keep them the same as the source field name.

6. Click OK. Click Close to close the dialogue after processing.

7. Check the attribute table of the  wells_hydro_geology layer.

Wells with sampled data

In the next section we're going to join the new attributes with the Shire groundwater monitoring wells layer so we don't need to add this layer to the GeoPackage.


7. Join attributes

In the last section we've created the wells_hydro_geology shapefile layer which is a copy of Shire groundwater monitoring wells, but then with the geology and hydrogeology attributes added. To add this layer to our GeoPackage we could drag the wells_hydro_geology shapefile in the Browser panel into the GeoPackage. However, then we would have two very similar layers.

In this section we're going to join the new attributes from the wells_hydro_geology layer to the Shire groundwater monitoring wells layer.

1. In the Layers panel click right on the Shire groundwater monitoring wells layer and choose Properties.

2. In the Layer Properties dialogue click the tab.

3. Click the Add new join button .

4. In the Add Vector Join dialogue choose wells_hydro_geology.shp as the Join layer. Choose No as the Join and Target field. Check the Joined Fields box and collapse the options there. Check the boxes of MaIHGComb and MaIGLG. We don't need a field prefix so we check the box Custom Field Name Prefix and delete the text.

5. Click OK.

The Layer Properties window will show a summary of the settings.

6. Click OK to close the dialogue.

7. Open the attribute table of the Shire groundwater monitoring wells layer to check the result.

Joined attribute table

The attributes have been joined. However, when we remove the wells_hydro_geology.shp layer, the join will be broken and the attributes will disappear. In order to prevent that we can copy the attributes with the field calculator.

8. Toggle on editing by clicking the button in the attribute table of the Shire groundwater monitoring wells layer.

9. Click to open the Field Calculator.

10. In the Field Calculator keep the box checked before Create a new field. Type Geology for the Output field name. Choose Text (string) for the Output field type. You don't need to change the Output field length. Expand Fields and values in the middle of the dialogue and double click MaIGLG to add it to the expression.

11. Click OK.

You'll see that the new Geology field has been added with a copy of the MaIGLG entrees.

12. Repeat steps 9 to 11 to copy the MaIHGComb field to a new field with the name Hydrogeology.

13. Toggle off editing by clicking and click Save.

This should be the result.

Shire wells attribute table with Geology and Hydrogeology fields

14. Close the attribute table.

15. Remove the wells_hydro_geology.shp layer from the Layers panel.

16. Check the attribute table of the Shire groundwater monitoring wells layer again.

You'll see now that the joined fields have been removed, while we still have the copied fields for Geology and Hydrogeology.

Attribute table after removing join

17. Save the project by clicking .

Now the GeoPackage of the project is ready.