 So today, we're going to talk a little bit about how to calculate mean values of spatial data. And our example we're going to use is precipitation over an area. We've already seen this example here, where we have some data. In this particular case, this is rainfall data located at a different number of rain gauges around a set of watersheds. And here are these four watersheds sort of combined together to be an area of interest. And we might be interested, for example, in talking about the total amount of water that falls on this watershed. And in order to calculate that, we might be interested in a mean or an average value for the depth of the water on the watershed. Well, which value do you use? We have 10 different values here associated with different areas of the map. There are multiple ways that we can go about approaching this problem. There are three typical ways of doing this, of approaching this problem. Here are the first three standard methods. The first is the simplest. It's simply taking the arithmetical mean, which we'll see in a moment. The second is to make use of theson polygons. And the third method we will look at is a contour method for using isopleths. Now isopleths is the general term for same values, where the values can be any sort of measurements. Often, when this is referring to precipitation, this would be what we would consider an isohyetyl method, where hyetyl basically means the measure of the rainfall. This applies just to our precipitation. All three of these methods use the same basic structure. What we're going to do is calculate a mean value, represented the value being x, represented the mean with the line over it. The mean value is going to be calculated as a weighted mean, where we're going to take the individual values themselves, multiply them each by some weight that gives them a greater or lesser relative value. If we sum all those weights, we will get a product, a sum of all these products. And then we need to renormalize by dividing by the sum of all the weights independently. This same formula will apply for all three methods. The methods just differ in the choice of what values we use and what weights we use. Let's consider first the arithmetical mean. So if I take a look at my map and I see the various values on the map, I notice that there are 10 of them. The arithmetical mean, in this case, is pretty simple. We just need to list the 10 values, the values themselves, the depths are going to become our values to find the mean of. So let's go ahead and list each of these values. Here's our values xi, and we're going to make them equal to the depths at each of these points. So if I record all of them, 3.86, 4.55, 5.06, 6.24, 4.39, 5.43, 4.67, 6.01, 4.66, and 5.37. These are all the values taken from the map. You can see each of them located on there at each of the different points. And it's important to recognize the units of each of these. Let's go ahead and assume, even though they're not given here, that these are all measured in inches of rainfall. So I'll use these two little quotation marks to represent inches. So we have inches of rainfall. In the case of the arithmetical mean, our weights are simply valued at 1, 1 unit. The unit is actually unimportant. But in this particular case, our weights are simply valued at 1. In other words, each of these values has an equal amount of weight. If we, of course, multiply those two, you simply get the same value, 3.86, 4.55, et cetera. And if you remember, we want the sum of the weights times the values. Well, in this case, that is just the sum of all of these. Same thing as the sum of all the points di. If we add all these together, we get a total of 50.24 inches. If we add up all the weights, we find that there are 10 elements. Usually, we use the letter n to represent the number of data points we have. So our n is equal to 10. And as you'd expect from the regular everyday mean, you sum up all the values, xi, which are our depths here, and you divide by how many you have, our mean there of 10 or our value n. And in this case, we get a mean depth of 5.024 inches. So that's the simplest version. And we could choose to use the depth value of 5.0 inches to represent everything in here. Obviously, that's going to be not as good a representation for this area b here or for apps for this area c where the 4.39 is. But it is an average value represented by all the data. This is a particularly good value if you have a pretty good distribution of data and if there's not a significantly wide variation in the data. In this case, the variation is pretty substantial from 3.86 up to the 6.24 value. That's a pretty substantial variation. So maybe we should have some concern about using the arithmetic mean as our mean spatial value. Our second method is the method using theses and polygons. So if you recall from a previous video, we've taken this same area and we've gone through calculations to divide that area up into a series of polygons called theson polygons. Where the area inside each polygon is represents all the points whose nearest gauge or whose nearest data point, all the points associated this group of points here in d5 or all the points whose nearest data point is this point d5. Anything outside that polygon has another data point that is closer to it. And in this way, we'll associate all the points of our area with a particular data point. Now one way to go about doing that is to take the grid you have and to overlay it with a graph of areas. In this case, it's not a particularly detailed graph, although we have fairly good detail on the number of data points here. But notice I'm making an assumption. I'm not counting half of grid points. We're making assumptions here on whether or not a particular unit of area is associated with a particular data point. And in each of these, I'm counting the number of areas. There are 14 boxes of area associated with this value 3.86. There are 144 boxes of area associated with 5.06, 112 with this value 4.39, et cetera. And these areas, the area of each thson polygon, notice it's not necessarily the polygon itself. It's the polygon where it intersects with the area that we are interested in. In this case, it's the entire polygon for this polygon in the interior. But for the ones on the exterior, it is the intersection of the thson polygon and the area of interest. So let's go ahead and talk about how we apply our weighted averages to this data. For the thson polygons, we again let our values, our x's, be equal to the depth associated with each rain gauge. And we'll again record those same rain gauge values, 4.55, 5.06, 6.24 in this first column. Notice these methods are often applied using spreadsheets as they can do the calculations relatively quickly and in a very organized fashion. So here are the depths of each of our rain gauges. Now with each of those depths, we're going to associate a weight. And the weight we're going to associate is the area of the thson polygon associated with each of the data points. So for example, as we noted, the 3.86 has 14 units. And the units are actually unimportant. They are area units. I'm simply going to use a small box here to represent grid units of area. It turns out these grid units are probably 125th of a square inch, but that number is actually unimportant, as we shall see momentarily. So I continue to go ahead and record. I look for 4.55 and realize that there are 20 units associated with that value. I look for the 5.06 and realize there are 144 units associated with that value. And I continue to make those associations for each of the measurements that we have here. 5, 112, 87, and this is transposed. This should be 5.43, 98, 130, 11, and 50. Now that I have each of those weights, we're going to take each value and multiply it by the weight. And we'll make a column here with the product of the weights times those values, which in this case will be the areas times the depths. In fact, the way you can think about this is we're actually creating small volumes of rain associated with each polygon, the volume that falls in each polygon. When I make that multiplication, I get a series of values, 54.04 box inches. Notice these are sort of strange units. If we wanted to actually know the depths, we would actually have to do something to turn these boxes into larger spatial area. But for now, we're going to keep these units box inches. If we multiply these two values, we get 91.00 box inches and continue until we have found all of the products of interest. Notice some of these values are substantially larger than other values for two reasons. One of the reasons is that there is more depth associated with some of them. For example, where there are six inches of depth, there is more. The other reason is there are more, there's a larger area associated with some of them. Now that I have these products, I'd like to take the sum of these products, the sum of the weights times the values, or in this case, the sum of the areas times the depths. Well, when I take that sum here, I get a value of 3,427.69 box inches. Well, that's not necessarily meaningful. But if I also then sum my total weight, that's this column here, which is actually the total area, I get 671 boxes. Again, that's the total area of the entire watershed measured in grid boxes. If I carefully count each of these grid boxes, I should get a total of 671. Now I take those two values and divide them, and I get a mean depth. Notice in this case, if I divide these two values, the units of box will cancel out, leaving me with an answer in inches. So my average value, which is the average depth, is going to be 5.108 inches. A little bit larger than the 5.024 inches we calculated using the arithmetic mean. But again, the same sum of weighted values divided by the sum of the weights. For our third and final method, again, because it's precipitation, we'll term this the isohyedral method, we are going to need the contours that we created. So if I take the map, and in a previous video, we created a contour plot representing different intervals of rainfall depth, where each line here, each isohyet, or each contour line, represents here as a depth of 4 inches, here as a depth of 4.5 inches everywhere along this line. It's connecting depths of 5 inches, and we go up 5.5 and 6. Well, I want to do the same thing with that, but I take that and map it again onto a grid. And in this case, we're interested in the area that's within our watershed, within the area of interest, but also the areas that are in between any two of our isohyets, so within the interval. Now to do this method, we're going to use different things for xi and for wi, for our weights and for our values. We're not actually going to use the values here at the rain gauges. We're instead going to use the values that are associated with the contours that we've created. Let's consider first, we'll list the isohyets that we chose here. In this case, the ones we chose were 4 inches, 4.5 inches, 5 inches, 5.5 inches, and 6 inches. You'll notice the values of the lines that we're using here. And what we're going to need to do is choose some centers for each of these intervals. For example, between 4 and 4.5, we're going to choose a central value, which is the average of those two, 4.25, which we're going to use to represent everything in that interval. Between 4.5 and 5, we're going to use the average, which is 4.75. So even though we have isohyets or isolines at certain values, we are going to now create interval centers that are between each of those values. One of my interval centers I'm going to choose as being the minimum value on my map, 3.86. We could choose something that's lower, assuming that there was another value of 3.5. But if this is a minimum value, we do not know if things go back up or if they get any lower. So one of the things we can use to bound everything is to use our minimum value and our maximum value. I believe it's the 6.24 over here, as actually the 6.24 isn't on our map. We'll go ahead and use the maximum value of 6.01 that is on our map as bounding centers, 6.01 on the edge here. But all the other centers will be values that are halfway in between the isohyets, 5.25 inches and 5.75 inches. Notice these are values that are in between each of the successive pairs of lines. Now that we have those interval centers, we're also going to use some interval weights. So our weights, our wi here, our xi are going to be the interval centers, and our wi are going to be the interval weights. Those weights are, again, small box areas, in this case of different colors, associated with the space between any two contour lines. If I look here, there is nothing inside this contour line, so there is a weight of 0 associated with that value 3.86. If I look for the blue color here, I see there are 33 units here, plus an additional 15 units inside here. So that's a total of 48 grid units, which all, again, represent with the box. For the green, this is between 4.5 and 5. I see 65 units, which includes this space over here, plus another 155 units, which is a total of 220 grid boxes. There's 220. As I continue, I will count 327, which is already counted for me of the orange interval, and then finally summing the two pink groups. We have 57 and 18. That's 75 boxes. And there's one small box here that's above the value of 6, which we're going to go ahead and assign the peak value there of 6.01. But there is only one box there, so it will have a minor overall effect. As in all the other calculations, we're going to take our values and multiply them by the appropriate weights, xi, wi. The first one has a value of 0 box inches. And the others are found by similar multiplication, 204, 1,045, 1,716, 431.25, and finally, 6.01. And again, all these are measured in box inches. Now that I have all these products, we're going to sum them up. And similarly, we will also want the sum of the weights and create that space over here. The sum of the weighted products there is equal to, in this case, 3,400 and 3.01 box inches. And the sum of all the weights is equal to 671 boxes. Notice we must have made a slight variation in our count from the last example where I believe we had 670. Oh, no, both of them are 671 boxes, so that's good. Now we'll divide these two values. And when we do, our mean value is going to be 5.072 inches, again, where the boxes will cancel out. So again, the area units you use are unimportant, because when you divide by the weights, they will end up canceling out. For our three methods, we got the following values. Method number one, using the arithmetical mean, we got a value of 5.024 inches for our mean depth. For number two, for our thesis in polygon, we got a mean value of 5.108 inches. And for our third method, our isohyetal method, we got an average depth of 5.072 inches.