 Hello, this is Hans van der Krust, Senior Lecturer at the IHC Delft Institute for Water Education. In this video I'm going to show you how to do spatial interpolation in QGIS. We're going to look at two interpolators. The nearest neighbor interpolation, which is also called the t-cent polygon or foranoid tessellation. And the second one is IDW, inverse distance weighing. At the end of the video, we'll compare the two interpolators and I'll also show some other interpolators you can use in QGIS. Now we're going to do the interpolations. And you find them here under the raster menu. And they're under analysis. And the first one that we're going to do is a simple nearest neighbor interpolation. So I have here the k and my stations. And I keep all the things at default, but I have to choose here the z value. That's the value you're going to interpolate. So that's very important to fill in something. Otherwise it will still run, but with an empty map as a result. Keep the rest as default. You see here that it prints the GDAL command. So GDAL or GUDAL is a very important tool in GIS. And basically QGIS has all kinds of dialogues built around GDAL commands. And if you are more fluent with GDAL, you can read this. You can use this in your own scripts. And for some things, it's really useful to use scripting. But that would be a completely different webinar in course. So I'm going to save here the interpolated result and go to chapter 2. And I call this TNM from nearest neighbor. And then I'm going to run it. And there it is. And you see that it takes the convex hull off your point. And that might not be what you want. So there are other interpolation tools in the toolbox where you can set the extent. I'm not going to demonstrate it, but that's what you could try. So you can use the IDW, which I'm going to demonstrate from the menu, but you can also use these ones. And in these functions, these tools, it's possible to set the extent to the canvas extent or to the extent of another layer or manually by putting the coordinates. If you use it from the menu, it will by default just set the convex hull off your points. Now, this doesn't look really beautiful yet. So I'm going to style this one. First, I'm going to drag my points on top. You see that the labels will remain on top, but not your points. That's always important. And I'm going to style this using the layers styling panel. And it is, it looks discrete, but it's continuous data. Because the definition of continuous data, and you can see that in my video on the theory of raster data is that it's a discrete data as integer and continuous data as decimals. And here clearly we have to deal with decimals. So we use single-band pseudo-color. And we have to invert the ramp again. So it goes from cool to warm. And this is what we in hydrology call t-cent polygons or foranoid tessellation. Basically what it does is assign the temperature of the station to the closest pixel. So therefore you get these sharp boundaries. That's what we often do when we interpolate the math data for models. Now I'm going to show you another interpolator. I'm going to uncheck this one. So we start again from the point. And that's the inverse distance weighing. That is an exponential decay function with a weight, so a higher weight to when it's near the station. And then the weight of the value decreases when you're further from the net station. To go into analysis and I choose inverse distance to a power. By default it's quadratic, exponential, but you can increase or lower that. So that's if you increase it, then it goes to the third power with the weight and if you lower it, it goes to the first power which doesn't make much sense. So also here we choose the Z value as temperatures and output data type. You don't need to change it because it's floating point. So that's okay. And I'm going to save it. It's the same g-dog command, but then with some different options to get in first distance. There it is. I'm going to run this and there it is. There's also a rule of thumb that you never should believe the automatic legends that come out because the software doesn't know what you are looking at and how you want it to be styled. It might even estimate the minimum and maximum value. So never draw conclusions based on the legends that it automatically produces. The good way is to just go to the layer styling panel. If you want to know the distribution of your values, you go here, compute the histogram and you get the real minimum and maximum. You can also see it here. These are the minimum and maximum settings. We're going to play a lot with that in other sessions. So stretching colors over certain range. Here we go to a single-bam pseudo color and we can again invert the color ramp. And now we have a more smooth image. So not like the T-some polygons, but more smooth because of the exponential relation. That's nice, but now we don't see the map in the background and there are some ways to solve that. So let me go to the styling panel. So the classic way is to use the transparency. So you can play here with the opacity. But that works a bit like a haze, so you can see. A better way to do that and that's really nice about QGIS is that it has implemented these blending modes. There are many ways of doing blending, but if you want to simply mix one layer with another, then you use multiply. And now we can see our OpenStreetMap layer through the temperature roster. It's mixed and we don't get this haze that we have with the transparency. So that's a nice result. Can do the same with the nearest neighbor. So one thing that you can do is to copy the style that should make the legends exactly the same, so paste style. And I check this off and put this on. So it's also with the blending with the same color ranges. And now the question is which interpolator is the best? Now, when you're with me in class, we will have then some discussion about it interactively. I will not do that now. But you can put your answers in the chat and we can see in the end, which you think is better. Is it the decent polygons, which is simply assigning the closest value, the station's temperature to the closest pixel, or is it inverse distance weighing? Which says, well, okay, if we're close, it's probably more like the temperature and then exponentially the weight of the case when we're further from the station. I'm going to give you the answer in a bit. You can still answer in the chat, keep it a bit exciting because we're first going to interpret the results. Because that's important with click, click, click in GIS. You can always create a lot of maps and people create a lot of fake news by inverting color ranges using wrong colors. So it's always important to look at the interpretation. And what we see here is that it's warmer at the coast. And it's colder, more inland. Why is that? Well, if you're in hydrology and know about water, we know that the heat capacity of water is much higher than of land. So in this case, we can even guess the season. In Netherlands has a temperate sea climate. And that means that in summer, it takes a long time for the water to heat up. And when it gets autumn, it takes some time for the water to cool down. So given the gradient, we are here in autumn and also given the temperatures. Well, if you're not from the Netherlands, you might not know this, but this is not very warm like in summer, but it's also not very cold like in winter and it's in fact early autumn. And we've seen if you check the attribute table, you'll find that there was a date field in the table and it's in September. So that makes sense. So that's a way we can explain this gradient from warm to cold, from the sea to the land. When we are in spring, we have the opposite signal where the land warms up faster and the sea is still cool. Now the cliffhanger, yeah, what was the best one? In order to demonstrate that, I'm going to switch to another QGIS project that I've prepared before. And we're going to use the 3D viewer of QGIS. That was developed by Lutra Consulting, the same ones that sponsored these sessions. And that's really great to visualize your data in a different way. I had to manipulate the data a bit because temperatures are not elevation. But what I want to show you is how you can display these temperatures as elevation. So high temperature, high elevation, low temperature, low elevation. And I'm going to show that. So I'm going to turn this one. And this is the inverse distance weighing. And what you see is all these strange mountains and valleys in your map. You see this color station just close to that station. The pixels become very similar to the value of that station. And then it averages out. It smooths until it comes at the next station. And here it goes up again. Now, yeah, the main question is, is this more natural than TISN? In my personal opinion, it's not. It is inverse distance weighing works very well when you have a very much denser grid of measurement points. But if you don't have any assumption on your data, then the TISN polygon with this sparse set of data is good enough. And then your best assumption is also that the temperature is like the closest station of any location in your study area. If you know about a trend like us, you can modify this model and include the spatial trend in it. If you're in areas with elevation, which is not the Netherlands, obviously, then you can add the lapse rates to an equation where you incorporate also the. There you can also incorporate the gradient of the elevation. Kurt asked if I can also show the other one in 3D. Well, I didn't do those conversions, but we have time. I can calculate it. You will see steps. Things can go wrong as a live demo and I didn't test this part. So we can give it a try, but I'm going to close this window then to create a bit of memory because it's quite intensive. And what I have to do is interpolate this one. So if you want to know the trick, now we're going to give away some secrets. That's the lucky 88 people here in the virtual room. So use the attribute table. I used a much larger number for temperatures in order for the 3D viewer to understand that this is elevation. Otherwise, the differences are too small. And then I put also a 99 times exaggeration on it to make it clear. That's not producing fake news for you, but that is just to make the visualization better. So I start from the same attribute table to do then the nearest neighbor. It's also good to see how I do that again. So that was under analysis and then nearest neighbor. And then I have to choose the column, this one, the big one. And I'm going to save it. And I'm going to call this one the TNM-1000 motif, the raster file, then I run it. And there it is. So it looks the same, but the values are much higher. And I go to view. So I'm first going to uncheck this one because I don't want to see it like that. New 3D map view. You find it on a view. There it is. And what you always need to do also like an arc scene is to define the elevation. And I want a DEM and we fool it. We say that's our TNM-1000. And I'm going to exaggerate the scale to 99. That's needed for this visualization. Otherwise you don't see much. And it renders. And now you see, don't look too much at the colors, but now you see the steps. The colors are a bit disturbing it. Let me just remove the colors, but you don't see these strange depressions, but you see steps. So still the question, which is more realistic. I still think this one is more realistic when you have no other assumption and you do a quick interpolation. But we can discuss that over the GeoBeers, of course. Some other interpolators that you can use can be found in the processing toolbox. So many people ask about cringing. Don't do that when you have so little points. Please, cringing, it sounds fancy and like that's the best interpolator. No, it only works when you have really a dense number of points. And all these more advanced methods work very well when you have many points. Otherwise, you should just stick to simple interpolators or build your own interpolation model with the DEM and lapse rates and those kind of things. I hope you've enjoyed the video. Please subscribe to my YouTube channel for updates. For more free materials on GIS, please check IHG Delft OpenCourseWare at GISOpenCourseWare.org.