 Okay, so for today the first tutorial is a bit more about processing the data and you will see some more things. There will also be some repetition of what we did before. So go to the GIS training on the OpenCourser platform and there's this first tutorial of today about creating a groundwater level map from borehole data and the DEM and you can download the data before doing the tutorial and it is a polygon with a boundary. It's an imaginary boundary because there are not many boundaries in the area that I wanted to use. You could use the boundary of a municipality or of an aquifer. Here I just took a random extent like you learned last time how to make a polygon of the extent. I'm going to download this folder because it's a shapefile. You know from good practice that the shapefile is not one file, so I'm going to download the zip file and save it to a new folder and I'm saving the zip file there and then I go to that folder, tutorial three and there's the zip file and I have seven zip, that's the tool that I recommend. It's open source for zipping and unzipping and if I click right, I can choose here seven zip and I can say extract here. What's always good practice is first to open the zip file with seven zip, open archive and then you can see if there's folders in it or files. If there's a folder in it then you will extract it at the folder level. In this case there are files so we'll just extract the files in the sub folder which would be good enough. I'm going to extract all these files here to tutorial three and there they are. I can remove the zip file not to get any confusion and there it is. Then I can start with the tutorial and we will load again a data set from a geonode. We will calculate the density of boreholes within that study area. We will download the SRTM one arc second digital elevation model, click and re-project it and then we style the DEM and we sample the elevation from the borehole locations and we compare it with the elevation attribute which was registered at the boreholes. We make corrections to the attribute table and some calculations and then we're going to end with an interpolation of the groundwater levels at the boreholes to a raster file. I'm going to start the tutorial. It starts with getting the data set from a geonode. We're going to work on the stump rate transboundary aquifer and we get that data on the boreholes from the orange Senku river basin GIS server which is a geonode and here it is. We're going to use data from the area which is called stump rate which is a place and there's some data about stump rate. It's a transboundary so have a look at it. The geonode you can always look at the meta data. You see it's in Botswana, Namibia, South Africa. It's a real transboundary and we're going to focus on the stump rate which is approximately over there to look at the hydrogeological situation there. You can check the attributes and it comes with quite some attributes that are registered with this layer in the geonode. As we learned we can make a connection with QGIS so we're not going to use the download option and get a zipped shape file but we're going to make the connection. I'm going to move to QGIS and follow the steps of the tutorial. First of all again the tip you can put your layers panel over the browser panels. We have the two tabs and I'm going to start with making a new geonode connection to this server. Click this button and go to geonode, make a new connection and this site is called irasicum and the url you can also copy it so here put the url. Don't make typos better to copy it and I'm going to test the connection and again we are depending on the internet and it says the connection was successful it's a valid geonode instance so that's great so I click okay and I'm going to connect to load the layers. It will give an error but this error doesn't affect what we do so if you click okay you will still get all those layers and what I'm going to do now is look for this stump rate data so I'm going to filter on stump rate and there you see it and remember that there are different web services and if we really want to work with the vector data we need a wfs web service and the one that we're going to use was the one that we were looking at that's this one and then the wfs so I'm going to click add and then it will take a bit because it's a very big data set so let it load I'll do close and we'll just wait for it to load many points but we will make it more useful by cutting it later to a specific study area you see the progress and there it's coming many many points great that these data sets are available on sdi so you can use them um so we're going to the next step and that is that we want to export this to a local file so you remember maybe how to do that so click write and I do export save features as and there I'm going to save this to a new geopackage that I'm going to make for this project I'm going to give it a new name that I call stumper data that's the name of our geopackage where we're going to store all the layers and the name of this layer we'll just call this one bore holes and I also want to change the projection uh to the projection that we use in this area which is uh utm zone 34 south on wgs 84 so I click this button to set the projection and I use the epsg code so three two is for utm seven is for south and then you get the zone number 34 and then don't forget to select it here so you can see that it covers our study area I click okay it's filled in here and uh that's all to save this bore holes layer with the projection in our new geopackage and to add it to the map so do okay they'll take a little bit to convert it and there it is in a different color uh qgis just assigns random colors to this you can always use the styling panel to style this and we don't need the geonode layer the online layer anymore so I'm going to remove it and you see that if I hover my mouse over it that it will say that it's the layer in the geopackage with the utm coordinate but you can also notice here in the lower right that on the fly projection of this project is in 4326 which means latitude longitude so I need to change this another way of changing it uh is to go here and go to set crs and then we can say set project crs from layer if I click this the project will have the same projection as this layer so that's a nice way to change the projection of the project and uh let's save the project at this point I'll just save it as a normal project let's call it stump read there it is and let's continue the next step is yeah this is a huge data set the attribute table is also very large and will take a lot of time to display so I'm going to make it smaller and I'm gonna cut it to the boundary that was provided so I go here to the browser panel and I go to our tutorial folder tutorial three I click right and I make it a favorite so I don't have to browse to this whole list and here we see the geopackage that we just created with the boreholes and here we have the shape file that we downloaded from the tutorial uh portal and I simply drag it there I can check the projection it has the same projection so that is okay so it means we can do all kinds of overlays with the borehole data I click right I choose zoom to layer and uh yeah it covers the point so let's style it a little bit go to the styling panel and I change the simple fill to a simple line make it red and make it a bit larger so this will be our imaginary study area so remember that you could choose there anything that is the boundary of your study area it can be the boundary of a administrative unit a national park or an aquifer or geological area that's up to you but here I just have this imaginary boundary and now we're going to clip the boreholes to this boundary and save it to our geopackage so we've done these things before you go to vector geoprocessing tools and then to clip and there I choose as an input layer the boreholes and as an overlay layer the stumped boundary and here you can check again in the brackets if they have the same projection that is very important and then I'm going to save it to the geopackage so always use this to browse and then save to geopackage and I'm going to choose here tutorial three stumped data save it will ask us how you want to call the layer and I'm going to call this boreholes clipped click okay and now it's going to clip it close and I can remove this layer and now you see we end up with only the boreholes inside our red rectangle now the next step is that we're going to calculate the density of these boreholes in the study area and therefore we use a processing algorithm so I'm going to close the styling panel I go to processing to toolbox and there you can find under vector analysis count points in polygons we need to first well mathematics if we want to know the density it's the amount of points and it's the area that it's covered and then we divide those so let's start with counting the points in the polygon and here for the polygon we choose the stumped boundary for the points we choose our boreholes that are clipped to the boundary and here you can change the name of the field of the count because what it will do it will make a copy of your polygon so it will create a new layer but it will it will copy all the attributes but it will add an attribute attribute with the number of points so number of boreholes and then let's save it to our geopackage and because it's still the polygon and it has everything that we need let's call it the stumped study area so it will be clear from now that we will use that layer as the study area boundary stumped study area and then I run it close and you see it's a copy of our rectangle we can copy the style paste it and then we don't need this one anymore and let's have a look at the attribute table so click right open attribute table and there we see that it's one feature that's this red polygon and the number of boreholes in the rectangle is 64 that's great but now we need the area of the polygon so what I'm going to do is I'm toggling on the editing and I'm going to add a field which has the calculation of the area and I want it in square kilometers so I'm going to open the field calculator and create a new field which I call area the unit so the user doesn't get confused later when they see the field and change it to decimal number wheel and you can calculate geometries from your vectors then you go here to the geometry function and you can choose their area so for a line you can choose dollar length and it will calculate the length of a line here we choose dollar area which works for polygons and it will give us the area here we see a preview that's the area in the map units our map units are square meters so I want to change it to square kilometers I'm going to divide it by one million oops and then the preview shows us the area in square kilometers and do okay it adds the area field so we're almost there we have all the ingredients to calculate now the number of boreholes per square kilometer which is the density so again we do that in this calculator and output field name will now be borehole density per square kilometer and that will be also a decimal number and there we are going to do the calculation with the fields and values and we're going to create the equation number of boreholes divided by the area and then we see the preview looks okay we do okay so the borehole density is 0.2 boreholes per square kilometer so it is just a demonstration of how you do calculations in the attribute table with these expressions I'm going to toggle off the editing mode and I'm going to save it now in the next section we are going to add a digital elevation model because we need the surface elevation also for the areas where it's not reported in the boreholes dataset and we need to compare those values close the attribute table and we're going to use the SRTM dataset that's the shuttle radar topography mission the space shuttle mapped almost the whole world at the one arc second spatial resolution for elevation using radar technology radar interferometry and the spatial resolution approximately at the equator is 30 meters and it's freely available and covers the whole static region and much more there are different ways there are different ways to download it so you can download it from the USGS website if you go to earth explorer then you can upload here the polygon you can go to datasets and you will find it here under digital elevation SRTM the one arc second and with this information button you can get more information about this data always important as you have learned to check meta data and this gives us all the data information on what this data is and how we could use that so that's important but we are going to use another way we are going to use a plugin to download it into QJS so I go to plugins manage and install plugins and there I'm going to choose the SRTM downloader that's a plugin to download the tiles of SRTM because it's a global dataset which is cut into different tiles and it will download the tiles of your map counters or in a specific study area you can choose that so I'm going to install it click close and it has added this button so I click the SRTM downloader icon and I'm going to set the canvas extent so it will use these boundary coordinates of the map canvas and uses it in latitude longitude so it automatically converts it and I'm going to define the output path where I want to save the file so I go to the tutorial three folder and I want it to be saved there and then I click download it will ask the username and password that's also on the earth explorer website it's the same username and password so you can click this link and make a new username and password I already have one so I'm going to give it here and you can choose to save the credentials so it will not ask it next time once you have submitted your credentials it will start downloading in this case it only has one tile because I chose a small area for this tutorial and then it says download completed that's great so here we have our SRTM one arc second elevation model and let's put the study area on top of it and we see that it covers much more than our study area so you can guess what the next step is so after downloading we are going to clip and reproject the DEM to our study area to do that well first of all let's check the projection of the global data sets are often in latitude longitude and you see here that it's in EPSG 4326 and that is latitude longitude while we are working in UTM so we want to change that and we want to clip the DEM to the boundary of the stamp read study area so I click write go to export and choose save us and I'm going to save it directly to our geopackage so change this to geopackage and then we browse to our geopackage so I have all the data together which is good practice I'm going to change now the projection and now I can choose it from the list because it's the projection of this project and I want to clip it to the boundaries of the stamp read study area layer so choose that here and it fits them to the boundary coordinates of our red rectangle I'm going to change the spatial resolution to 30 meters make them square and there's one more thing because we reproject it's important to define the no data value I check the box and I click the plus and I'm going to add minus 999 because there's no elevation that is minus 999 9 that's an out of range value and with reprojection it and clipping it might introduce some no data areas at the at the border and these will be assigned the value minus 9999 and the software that knows that it should not visualize those pixels that's all so I'm going to click okay and it's now added to the map you see a bit of contrast difference that's because the standard the default visualization of a layer is take the minimum and maximum value and scale the gray scale between those values and because we clipped it we have a different minimum and maximum value to scale the gray values I'm going to remove this layer so we end up with our clipped digital elevation model with 30 meter resolution now the next step is to style this one because it doesn't look nice in gray scale there are some nice tricks to to style it so I'm going to open the layer styling panel this is continuous data so for continuous rasters we always use the single band pseudo color and then we can choose a color ramp and I'm going to create a new color ramp and I'm going to choose here a catalog cpt city and that's a very useful catalog because you can find a lot of predefined ramps as you will see there it is and in all kinds of categories so I'm going here to topography and I'm going to choose elevation and I'm going to use this a ramp and if you want to reuse this all the time you can click save as standard gradient gradient and then it'll always be available in the list now I need to click classify and now it has our pixels in the colors of the color ramp that's one thing we can do now I'm going to duplicate this layer and that's a nice trick to style DEMs so I'm going to uncheck this one and check this one because it's duplicate it will be exactly in the same style but I'm going to use another render let me for good practice rename this one see I didn't change the layer name I guess in the geo package so you should call it DEM I left it as default so correct that when you go through the steps and I'm going to create here a hill shade so it refers to the same geo package but just in the layers list I give it another name so it's we can recognize what it is and then here I can choose the hill shade and for the renderer there's a hill shade renderer that automatically calculates on the fly the hill shades and we can see the shading here you see it's quite blocky therefore we need to change this setting of resampling and when it's zoomed in we choose bilinear and then you see that it's smoothed and we can also put this one on average when we're zoomed out and that improves a bit the visualization and when we blend this with the DEM so I go back to the DEM in the layer styling panel and I change the blending mode here to multiply and then we have the hill shades with the DEM and that gives a better visualization effect now this area is not very spectacular in relief but if you try to do that in other areas you will see that that gives a very nice effect that was the styling of the DEM then it's time to to look more at the data and what we are going to do is sample the DEM values at the locations of the boreholes and we did that before in another tutorial we need a plugin for that that is called the point sampling tool here it is install the plugin click close and it adds this button so I'm going to add it and what I now need is I want a copy of these boreholes clipped but then with the elevation values from the DEM added to it so I'm going to select here all the fields from the original layer the boreholes clipped layer I use shift to select them all and I want the DEM so I keep control pressed and I click on DEM so it's also blue so we can see here that every field that I want in the output is now selected in blue and I'm going to create an output layer so it will make a copy go to tutorial 3 I'm not saving it in the dual package because this tool will not add a layer but will overwrite it so I'm going to choose a shape file and I'm going to call this one boreholes z so I will recognize that this is the one with z values click save before clicking okay I go to the fields step and there you can rename the fields if needed and I'm going to do that for the DEM value I'm simply going to call this one z underscore DEM so I know that's elevation from the DEM when I click okay now it processes the dataset and yeah we can now work with the sample dataset so that's the next step we are going to look at the attribute table of this new layer I'm going to remove this one click write open the attribute table 64 records as we have counted before and we see different fields in the attribute table and for us what is important for this tutorial is that we have the elevation that is mapped at the boreholes but you see that there's a lot of missing data these minus 9999 are missing data values so some of these boreholes have missing records for the elevation at the borehole mapped before and we have some other useful fields we have our elevation from the SRTM DEM here added which we just did with the point sampling tool and there is a depth in meters which also has a lot of missing data but it also has some with data that we will later progress with so first I want to compare the elevation from SRTM with the reported elevation at the wells to see if they have a bit of a relation with each other so I'm going to select first the no data values because I don't want them in a scatterplot that we are going to create so I click this button select fat features using an expression and I want all the elevation features I go here to fields and values all the elevation values that are less than zero I want them to be selected so here elevation in double quotes that refers to the field name and then less than zero and then I click select features and I click close and I see that there are 10 features selected we see them here in bright yellow also on the map and those are the ones that have missing data for the elevation here's the elevation field but for our scatter plot that we're going to make with a plug-in we need to invert the selection we want to make the scatter plot for everything except those missing values so I'm going to use this button to invert the selection so now 54 records are selected those are the other ones and I can close the attribute table for now they remain selected and what we're going to do now is to make a scatter plot and we're going to use the data plotly plug-in which is a very nice plug-in to make scatter plots or other types of graphs from your attribute tables so go to plugins manage and install plugins and I choose here data plotly there it is and going to install the plug-in plug-in successfully installed I click close and I'm just going to remove the layer styling panel because when I click this new button here it will open the data plotly panel make it a bit bigger so we see the whole panel and here you can choose the type of plot that you want and I'm choosing here the scatter plot and I'm choosing the layer here boreholes set that's important and what we need to set is the correct x field and the y field but first I should not forget that I only want to use the selected features from the attribute tables I check this box and I want on the x axis the elevation and on the y I want the z from the DEM that we have sampled and I keep the styling as a default you can play around with that and I go to this tab to configure some more things I don't need a legend I'm going to change the title to borehole versus DEM elevation always important to define these labels on the axis with the units so good practice borehole elevation in meters and this one we call it DEM elevation meters and that's basically all the settings that we need now and then I can click this button here to create the plot and there we see our scatter plot and we see that they are related there are some outliers but generally it gives us a good correlation so we might in this imaginary case conclude okay if we have those missing data in the borehole data set for elevation we can replace it with the elevation values of SRTM as a substitute you could also go back to the field with an altimeter and then measure them the elevation again but here I'm going to show you how this will work to replace those no data values so that's the next step I'm going to close this data plot lead panel and I go back to the attribute table there it is and I'm going to deselect all I don't want this selection anymore because I'm going to work on this attribute table now and I toggle to editing mode and what you see here in the editing mode on the just above your field names is something that you can read as an equation so this is the output field equals and then this button to set the equation or you can type the equation here and I'm going to make an equation with a condition so I'm going to choose here elevation and what I want is a condition that if the elevation is no data so less than zero then give me the values from the dm otherwise use the values that were recorded at elevation so I go to this button to build the expression and here under conditions conditionals you can have different functions to make conditions we are going to use the if function and you can see the syntax here on the right if I'm making a bit bigger here if the condition is true do something that is here and then a comma what to do if it is false so that's the structure if I double click I can start building the expression expression it is written here and first I'm going to add the elevation field so go to fields and values and double click on elevation so it will be here in double quotes make it a bit bigger so you can read it better so if the elevation is less than zero then that's a comma it reminds me here about the syntax when it's true I want the values from the dm so I go here to z dm and I double click and then I write a comma and I say what it has to do when it's false so when it's not less than zero I wanted to add the original elevation values back so I double click and then I closed this function with the brackets and I see that the preview is okay so to remind you it's a condition if elevation pixels are less than zero if that is true then write for those fields the elevation from the dm if that is not true use the elevation values that were already there so I click okay and now the equation is written here and then you verify if the equation is well so elevation equals if elevation etc and only when that is the case you click update all and now we will not find any no data in the elevation field so we have so we have now every elevation every feature every borehole now has an elevation feature with data so that's great I'm going to toggle it off and save these results in this attribute table now we need to calculate the groundwater level in the boreholes because we have here the depth in meters not for all the boreholes but for some of them but we want to have the absolute elevation so I'm first going to filter out those no data values so I go here to select features using an expression as we learned before fields and values depth in meters and I'm going to say if that is less than zero so all those minus 999 values then I want to select them so I choose select features and it will select a lot of them we're going to lose a lot of these points in this case and I'm going to simply remove those so I go to toggle to editing mode use the trash bin icon and we are left over now with 11 points that we are going to use for our further analysis so I'm going to save this by toggling off the editing and click save and then I can close this and we see here those points now the next step is that we need to go back to the attribute table because I now want to subtract the elevator the depth from the elevation of the surface to have the absolute elevation of those boreholes which is the groundwater level so toggle the editing mode and I'm going to the field calculator and there I create a new field which I call groundwater level meters it's a decimal a real keep the other defaults and I go here to fields and values double click on elevation and I do minus and then the depth in meters and the preview looks okay make it a bit bigger so you can see it and this will give us then the groundwater level in absolute height so I click okay and what we have now here is the groundwater levels for these 11 points the toggle off the editing and click save now the next step is that I want to interpolate these groundwater levels to a raster to close the attribute table and we're going to use some tools to interpolate the first interpolation method that I'm going to demonstrate is the inverse distance weighing method and there are different ways to calculate it but I'm going to use a processing tool the advantage is that it will calculate it for the full extent instead of using the function that is in here here you also have inverse distance to a power but that will restrict the calculation to the convex hull or boundary of those borehole points so I'm going here to interpolation and I find here IDW interpolation I double click I want my borehole set layer as an input and I want there the groundwater level in meters as the layer and then I need to use the plus button to add it here to this list I keep the default quadratic weight quadratic function exponential function there for the decay function of the weights and I can choose here the extent and that's the advantage of using using this tool instead of the other one so I want to interpolate it to the boundary of the study area click okay and then it will use those coordinates then I'm going to save it here I don't have the option to save it to a geopackage so later if you want it in the geopackage you can drag it from the browser panel here I save it as a TIFF file and call it groundwater level IDW because later I'm going to show you another method and it will be a geotiff and then I run out sorry I forget one more thing to set the pixel size and I wanted at the 30 meter resolution not 0.1 that would be really too many pixels for this very low amount of points so put it at 30 meters in this case and then I run it and there we see a smooth interpolation that's what the IDW does it's always good to style this with a color ramp so I'm going to open the layer styling panel remember for continuous data we use single band pseudo color and I'm going to use a ramp and go now to all color ramps and I would like to have something like if it's very deep then it's not so good so that's red and if it's closer to the surface it's blue so I want something from from red to blue so I could use this one or I could use this one's in the tutorial or I could use red via yellow to blue so let's use this one in this case and there we have it so this is one interpolator but there's yeah it looks maybe nice and smooth but it's very much biased to the points and here we have very sparse distribution of points let me put the points on top of it and could also label those points with the values go to single labels and I choose then the field of the groundwater depth sorry that's the last field here and then then you can see it just a quick and dirty labeling you can change a lot of these settings so you see that we only have few points and the distribution is not ideal for this interpolator and I can make that even more visual what what works and what what happens here by visualizing this in 3d so I go here to view new 3d map view and that will open the 3d map view and what I'm going to do is change some settings here need to indicate that we use a dm and the dm that we use in this case is the groundwater level idw and I'm going to exaggerate it because you've seen that the elevation values are very little so I go to 10 and then I click okay and then I can see it in 3d and what you see is typical for these kind of uh interpolators is that it will create uh bumps and valleys around the points so another interpolator might be better than using this one just to visualize the result idw works very well when we have many points uh a bit regularly spread over our study area I'm going to show another interpolator that's the t-cent polygons and for that purpose I can use there the tool from this raster menu go to analysis and I choose grid nearest neighbor that's the t-cent polygon it will simply assign to each pixel the value of the nearest point so I choose here the bore holes z and it's important that here under advanced you choose the z field which will be groundwater level in meters and uh that's all I go here to save the interpolated raster to groundwater level and I call this one t-cent I click save and you see that it uses a gdalt tool I click run there it is now it's limited to the boundaries of our points so that's a result of this algorithm and I'm going to style it to compare it single band pseudo color the yellow to blue uh blue to sorry red to blue and so it's at the same color scale as the other one and yeah normally when I then discuss what which interpolator is is better students normally go for the smooth one but you've seen that those this one also has some strange effects if we look at it in 3d if we go to t-cent it simply says that the groundwater elevation is the same as the closest point so that's what happens with this interpolator so that's basically what I wanted to show you with this tutorial