 In this tutorial we are going to create a groundwater level map from borehole data and a digital elevation model. You will learn how to convert a comma-saparated values file with borehole depth and coordinates to a PC raster map. Then we are going to interpolate the borehole depths to a continuous raster using the inverse distance weighing method and the decent method. Let's first activate the environment here in the amaconda prompt. Conda Activate Tutorials Then we go to the folder where the data is stored. Here we find the CSV file and the clone map. Let's have a look at the CSV file. We see that the file doesn't have a header, but the first column is the depth and then we have the x-coordinate and the y-coordinate in some projection. And there is the clone map that we use for the spatial properties. You can visualize it. Here it is. You can also see the properties using the map attribute minus p command on the clone map. And there we see the number of rows, the number of columns, the cell size and the data type, the upper left x and the upper left y-coordinate, minimum and maximum value. Let's first convert the CSV file to a PC Raster map. In PC Raster we can use the call to map command. Here you see how you use it. Call to map, the input column file and the output file for the map. Then the different options that you have here. We can use it call to map. And then the data is a scalar, so I use the s argument. And then the x-coordinate, as you've seen, is in column 2. And the y-coordinate is in column 3. If they're in columns 1 and 2, then that's default. But here they are in different columns. And we have the data, which we use the v argument in column 1. So with x, y and v, you indicate which columns the x data, the y data and the attributes are stored. And then we use the CSV file as an input. It's a comma separated file by default, so we don't need to change the separator. And we need to specify the clone map and the output name. So first the output name. BoreholeGaps.map. And then the clone. What it will do now is it will read all the entries in the comma separated values file and resample it to the dimensions of the clone map. Here we see the result. It has read 220 records. There were no missing values. There are no records that were outside of the clone. This is the number of missing values and the number of cells that had more than one record. That means because you have a certain cell size that there can be multiple records in one cell. And then it has to choose one. You can read in the documentation how it deals with those situations. Let's have a look at the file. This is the file. It has many points here with the borehole depth. With Akila we can also query the points. I see the value. This one is 0. That one is 31. So now we have converted the CSV to a PC Raster map. We can do the interpolations in PC Raster Python. So I'm going to Python and we use IPython. And first I'm going to import PC Raster. And then I'm going to read our borehole depth map. If I use tap it will give me the files that are similar to the pattern that I'm typing. And then I can easily find the file name of the map. Now it is red. And to do the inverse distance interpolation we use the inverse distance operator. You can find in the PC Raster manual that it needs a mask. We will use the clone for the mask. So I'm going to read mask equals read map. And then for the points for the interpolation it's borehole depth. Then it needs coefficient, the weight. We normally use 2. So that means an exponential decay function, the exponent. And a radius, if we set it to zero there's no limitation to the search radius. And maximum number of points used in the interpolation. If we set it to zero there's also no maximum. So we're going to use the no maximum setting. So borehole depth IDW, inverse distance weighing equals and then the inverse distance operation. And then we use mask as an input, the borehole depth. And we use the power of 2 for the decay function. And no limits to the search radius and the maximum number of points. And we do enter and it will interpolate all these points. And let's have a look at the result. And there it is, a continuous raster with interpolated borehole depth. Another method is to use the T-scent polygons. And in PC Raster this involves the following steps. We need to assign a unique ID to each of the boreholes. Then assign to each pixel the closest borehole ID. And then assign the borehole depth to the corresponding borehole IDs. So let's first assign a unique ID to each borehole using the unique ID operation. The input needs to be a Boolean raster. To create a Boolean raster of the boreholes we use the defined operation. This will give Boolean true for all cells with a value. And Boolean false for all node data cells. So let's call it boreholes equals and then we use defined. We use borehole depth. So let's check what it made. And we see indeed that it's now a Boolean map with true for the boreholes and false for all the other pixels. And then we can assign a unique ID to each Boolean true cell. And note that we want the output to be nominal instead of scalar. Therefore we wrap the unique ID into a nominal operation. So it will become borehole ID equals... the unique ID of the Boolean boreholes that we created. But then it needs to be a nominal. So we add here a nominal. We wrap it in a nominal operation. So the output will be a nominal. There we are. Let's check the result with Aguila. And now we see that each of the boreholes has a unique nominal value. Now we need to assign to each cell in the study area. It's closest borehole ID. Therefore we use the spread zone operation. It needs a raster with the points to interpolate. In our case that's borehole ID. It needs the initial friction distance, which in our case we don't need. So we make it zero. And it needs a friction that is the friction for each cell which we keep constant at one. So that will make our creation decent ID. Equals spread zone, borehole ID, initial friction zero. And then for each cell friction of one. Let's check the result. And here we see our zones. A very nice and colorful map. Now we want that the borehole depth of each zone is assigned to the zone. The final step is to assign the groundwater depth values of the boreholes to the decent polygons. We can do that by calculating the minimum or maximum depth per class, a zone of function. And that we will extrapolate the value to the whole class. So here let's use area maximum, which will calculate the maximum within each class. And let's check the results of both interpolations. And there we see the different interpolation results. Now we can also create a script that calculates these decent polygons if we merge the code together. And we can do that in spider. So we control D to leave this. So to write the function in spider, we need to import PCRuster. And we need to then define a function. Let's call it decent. And it should have as an input the boreholes. The first step is to create the unique ID and then to give them a unique ID. Then create the zones and then assign the depth to the zones. We turn this in. So we can read a map with the borehole depth. And we can say depth decent equals decent depth. And then we can visualize the result and report it to disk. And this file is in the data folder. And there it is. And this way we can easily make functions that can be reused.