 So today we're going to talk a little bit about creating raster data from contour plots. This is particularly useful if you actually want a computer to be able to visualize the data you have. And we're going to do it by hand so we get a sort of a sense of what the algorithms behind what the computer actually does when they do similar algorithms. So we're going to look at an example that may be familiar to you. What I have here is I have a plot for some information, some spatial data. This is precipitation data and a few different watersheds. And we've already in some previous videos looked at different ways to interpolate this data. We took the data and we were able to, first of all, we laid it out on a grid. And the idea is that each of these grid pieces could have pieces of information associated with it. For example, this .4.55 up here in the corner is a precipitation value, but every single one of these grids nearby has a precipitation value of its own. Now to find that precipitation value, we would have to do some form of interpolating. Some sort of measurement that would say where this value was on the way from 4 to 5 over here, we probably have the values 4.7, 4.8, and 4.9, which we talked about in creating our contour plot. We took the data, we did some interpolating and found some lines of similar contours here, values of 4, values of 5, values of 5.5, and we're able to create a larger visual representation. But even with that visual representation, you could see that each of these little grid points could also have their own value. What we're going to do in this case is try to create a grid of values because those grid of values can be represented on a computer that each single one of those points could be colored in to represent the value that's associated with that point and allow us to see the data. When we do it by hand, we create lines, and then if I color in between the lines, you see we have these regions, these intervals that represent certain data values. Here, for example, we have a line representing a precipitation of 4.5 inches and another line representing precipitation value of 5 inches, and then it's sort of an interval in between which represents any data that ranges between these two values, between the 4.5 and the 5. What we're going to want to do today is again chop up or to grid to take this and grid these particular values. I've made a copy here so I can start my gridding. Here's a copy, it's black and white now, of my data. It's printed out on a graph paper, a piece of graph paper here. A couple of pieces of information I might want to know. It looks to me like my data extends over 48. There are 48 grids here that have data, and the only data here is sort of a coloration of which interval each of these grids is in. I have 48 grid spaces horizontally here and 30 grid spaces vertically. The first thing I want to do is I want to decide just how detailed I want this map to be. How detailed I want this grid to be. Do I want to count and figure out values for every single one of these little teeny grid spaces? Or do I perhaps want to think a little more carefully about how many grid spaces I want to use? Perhaps instead of me doing every grid space, I can look in grid spaces in chunks of 3 or chunks of 5 or chunks of 2. In other words, to be maybe a little less detailed in my representation here. So what I'm going to do here is I'm going to look and I'm going to make a choice. I'm going to say, what if I divide this up into blocks of 5? Well, I can do that in blocks of 5. The problem is I have 48 units going all the way across, so I'm either going to leave out some of my data, or these aren't going to be divided up quite evenly, but I do want to divide them up evenly. So I'm going to eliminate a little bit of my data. I'm going to look here and realize that there's not much change in the data over on these last three rows or so. And if I look on the right side of my board, there's not much data change over here. And I'm going to go ahead and decide that I'm going to break this up into blocks of 5 by 5. But I'm going to start my first block, maybe two units inside, so make sure I capture my actual data point. And if I do that, go ahead and draw a line all the way down the side here. And then I'm going to count out 5 grid units, 1, 2, 3, 4, 5, and draw another line and continue that process all the way down, chunking my data up into 5 unit columns. Then I'll do a similar thing to create 5 unit rows. I'll do part of it here, but 1, 2, 3, 4, 5 units, and create a grid of 5 by 5 boxes. And I continue this until I've gridded out the entire piece of paper. I've already completed that here. So here's an example of the same data. So I've gridded this out into 5 by 5 units, and this has determined the resolution of my graph in 5 by 5 units. So if you look here, I now have to make a decision. What I want to do for each of these grid boxes is to assign a value to the grid box. I need to assign a value to each space in the grid box. And I have a second sort of grid here that I can record those values on. But I need to make some choices. I need to make a decision on what value I'm going to put in the grid box. You'll notice for each grid, I've selected a center point. This is one way that we can go about and think about the values that we want to use within the grid box. For example, if I look at this point value here, I have a number of choices that I can make. Now this value is almost right on the line of 4.5. I could say, well, the nearest line that's to it is 4.5, and I could decide that that's the value I want to use, a value of 4.5 because I'm going to use the nearest interval break. That's one choice I could make. Another choice I could make is I could say, okay, for example, let's take something like this point here. Notice this is somewhere in the middle of the interval between two interval breaks. And here is the 5, here we go, the 5-unit line, and this one here is the 4.5-unit line. And I could make an estimate or even a measurement here and say this is somewhere between 4.5 and 5, and estimate that as being perhaps 4.7. I could divide this up into five parts, one, two, three, four, five, roughly five parts, and I could record that as being 4.7. So I could do some sort of interpolation. If I interpolate it over here, perhaps this value is closer to 4.9 and this value is almost five. So that's another method that I could do. But notice that takes a fair amount of work that at each of these points I have to make some sort of guess as to what value is appropriate. The other thing I could do is I could look at a point, for example, this one here, and I could just assume that because it's in this range, in this case it's in the range of 4 to 4.5. So what I could do in this case is I could say, hmm, I could look and see this entire thing is all in the value of 4 to 4.5. So maybe I could just assign a value based on the interval. In this case, the interval runs from 4 to 4.5. So I might actually call this a value of 4.25. In other words, the mean of the two intervals from the 4 to the 4.5. I could make that choice, but notice that's simple for something like this, but not as simple for something like this. In this case, I have a portion of it that's less than 4 and a portion of it that's greater than 4. I have a bunch of options. I could choose to count the number of grids, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, that I associate with the interval value of less than 4. Maybe I call it 3.75, and about half of it that's associated with 4.25. Well, that's going to give us a value of around 4. Okay, but then again I'm starting to make calculations and making calculations doesn't speed up my ability to identify a value for this. So we have many choices, and our choice is sort of boiled down to this idea of more accuracy equals more work. The more detail I put into calculating a value for each of these, the more accuracy I'm going to have, but it's going to take me longer, and that detail and accuracy may not give me more information, really, in the overall pattern that I'm looking at. And you have to recall that all of these lines that were drawn here originally were all interpolations from the original data. They're all data that came from the only solid points we have is where the data was actually measured, and these are all interpolations in the first place. So for this example, I'm going to simplify. I'm going to simply think about this example as being, I'm going to take the center value and read that center value as being the value for the entire interval, which is halfway between the lines on both sides of the interval. For example, this is going to be, this third block here is going to be a value of 4.25. And similarly, this one will also be 4.25 because that center value is in the interval 4.25. If I continue and follow this interval, I notice that this one over here is also 4.25. This one here is 4.25. This one here is 4.25. And that's a very simple way of doing it, that I simply determine what value, what interval the center is in and assign it that value. This one over here is greater than 4.5 and less than 5. So the value I'm going to give it is 4.75. These here are less than 4, but greater than 3.5. So we're going to assign this value 3.75 as well as this one here, 3.75. Notice we've simplified my reading of each of these values, because we've determined that that's a level of accuracy we're okay with. Now it's a little bit harder with this one over here. It's right on the line. The line of 4.5 appears to run very close or right through it. So I have to make my decision whether or not I want to count that one as again being in the interval 4.5 to 5, which would be a value of 4.75. Or if I want to make, oh, maybe I'll just make a little change that if the line runs through it, I can use the value of the line. That's a decision I can choose to make. It's easy to make that decision as a human. It might be a little harder if I'm programming on computer to make that read. So I kind of have to make a strong choice here. I'm going to go ahead and make the human choice that if this line runs through that dot, that I will use the line value. But otherwise I will use the interval value in between. So here I'm going to record this as, it doesn't quite run through that line exactly. So I'm going to record this as 4.75, assuming that this is in the dark interval. However, the one right below it is, line runs right through. It's hard for me to make any decision about which one to put it on. So I'm going to go ahead and call this, let's see here, the line here is the 5 line. So I'm going to go ahead and call that a value of 5.0. And I continue with this process. Here's another point. Notice this is the interval from 5 up to 5.5. 5 to 5.5. So the value here we're going to call 5.25. 5.25. Here's another example of one that's exactly on a line. It's on the contour line representing a value of 5. So for this one I will go ahead and record a value of 5. So notice basically every one of my intervals here is either going to be 5, 4.25. It's going to be some value every quarter of a unit. 4.25, 4.5, 4.75, 5, and so on. Notice we're not as detailed in this particular case here where I said I could have read that one as being something like 4.7. The value I'm going to choose here is the one that's halfway between the two and this is our 4.75. So to finish this process I go through every single square on the grid and I read a value associated with that square based on whatever rules I've chosen to interpolate, whether they be simple ones like I've chosen here or more detailed ones like interpolating in between. And if I do so I get a full grid that looks something like this. Now following along with our more accuracy equals more work I might choose instead to represent this with a greater resolution. What do I mean by greater resolution? It means that I'm going to have more data points by having smaller grids. Again, the same process can apply here. I can look at each of these points and record a value for each of these points in the same way that I recorded a value for the points in the previous version. For example, if I look in this upper left-hand corner that's a value somewhere between 4.5 and the line of 5 so I might record that one as being 4.75. Whereas in this case here it looks like that line runs right through the middle maybe I record that one as being 4.5. This is in somewhere between the line of 4 and 4.5 while that 4.25 as we will with each of these other three points 4.25, 4.25, 4.25. And we can continue that same process just as we continue the process on the previous case. But again, more accuracy equals more work. Yes, I'm going to have many more detailed points but it's going to take me a significantly longer time to do so. For example, in the previous version we had 1, 2, 3, 4, 5, 6, 7, 8, 9 1, 2, 3, 4, 5, 6, 9 by 6 is 54 units to calculate. Whereas here I have 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 160 measurements to make. So I will have much more detailed information but it's going to take me a longer time to do so.