[MUSIC] Hello everyone and welcome back, in this lecture, we're going to dive into ModelBuilder by building our own model for the first time. So I'm going to show you how to create a brand new model and then, how to add tools to it, link them together, and make your own geoprocessing tool out of it. So, let's start with a scenario, let's say, that you regularly need to take a new area of interest, and find all of the south facing slopes for it. And that you have the digital elevation model or you can obtain it from somewhere but you really need to find all the south facing slopes that you could find. Or it's that you could use it for vegetation analysis, or solar influx, or something like that, well we've done this before in one of the assignments. What we need to do is we need to run the aspect tool on the digital elevation model. And then we can use the raster calculator to find all of the cells in the aspect raster that face toward the south that raster calculator step could be a little error-prone. So we might want to make a model for it so that, we can save time of running two steps and that we can have consistent results. So to start with, let's create a new tool box that we can put our tool in, so find a working directory on your computer somewhere. And, In the Catalog window, right-click on the folder that you want and go to New, Toolbox, Not Python Toolbox, in this case we're doing Toolbox and I'm going to call it. DEM_Tools and now, I don't have to add it to arc toolbox but I tend to like to, so let's go and add it to arc toolbox again. So I'll right click on arc toolbox, going to add toolbox. And then find that folder, click on it once again, and then click open. And what I'll get when it finishes outing it is a new toolbox with nothing in it called DEM_tools. Now, to create a new model or geo-processing tool all I have to do is right click on it and go to new model. And a canvas pops up here immediately that says Model, and then in my toolbox, I get something that says Model. I'm going to close the canvas really quickly, and I'm going to rename this now, because otherwise, things get a little confusing. So I'll right-click on the model, go to Rename, And I'll do, I'll call it find south-facing slopes and hit Enter to save it. And now if I double-click it, it brings the geoprocessing tool version of it and it says this tool has no parameters and that's not what I want. So I'll close it and I'll right click on it again and I'll go to Edit and now the window says find south facing slopes. So, that is the name of my tool, so first things first, let's pin our geoprocessing tools out so that we can see them a little more and I am going to expand my canvas. And the easiest way to get new tools onto our canvas here is just to drag and drop them. So the first thing I want to do is under the surface tool setting spatial analyst, drag the aspects tool onto the canvas and what I get is just the tool and its output roster. And the next thing I know I want is I'm going to want to run aspect on whatever input I provide and then But in output. So I need it to get input for it if I'm going to make this a geo processing tool. So I'm going to right-click on aspect and go to make variable from parameter input roster. And now I can See the, what is generally the input raster for Aspect which is our DEM. And it’s filled in to Input raster because that's the variable on the canvass with the name that I can use. And, what I'll do is rename this now by right clicking on it, going to Rename, I'm going to call it DEM to make it clear. And now, if I don't click on aspect I can see that the infrastructure is the variable DEM that I have created here.I will click okay. So now I can see I provide DEM to the aspect tool and I get an output raster of some sort. Let's name rename this nuclear two and we'll call it aspect raster. And as I said we know that after we get the Aspect raster we need the process it to find the south facing slopes. So we'll use the raster calculator for that and I'll just drag that onto the canvas two. And here's some of the power of Model Builder, I can just click with this little connector tool. I can click on, Aspect raster and pulling the mouse down and dragging I can release it on roster calculator and make it as input and I'll put it as map algebra expression for now. And it won't be complete and in fact it's not letting me do it because it's an incomplete map algebra expression. So, a lot of times we can connect tools that way but this time we can't so I'm going to double click roster calculator and we're going to make our own expression right now. So I'll double click Aspect raster and I get a slightly different format here because it's reusing the layer within the model. So it turns it in percents and quotes and what I really want is all of the cells that are between some value and another value. Where those values are the south facing slopes but I can't remember what those values are. So let's take a look really quickly, let's just look on Google for. Aspect raster values, we can look this up pretty easily and let's check out how aspect works in ArcGIS desktop help and here we go. There's only this diagram saying basically what degrees are which on the campus roast, I want between 135 and 225 or so to consider it sold. So let's say greater than 125 then we'll do an end and I'll add aspect raster again and say less than 225. And we'll see if that calculation works and I'll leave the output as it's default right now and I'll click okay. And now, I see that it makes that connection for me, it knows that I used it in the Raster Calculator and that the output of Aspect goes as an input to Raster Calculator. Now, let's right click and rename this South Facing Slopes and now we have a relatively complete model. But as we saw last time, it's not in color, it's not ready to run, why is that? Well, it's because the DEM isn't, we haven't provided the DEM parameter and it may not know where to put the aspect roster. And so I'm going to right-click on that and say Managed, because I don't really care where that is. I'm really looking for this output here and so I'll let ArcGIS control where this goes. Now, finally, we can test it out in our model builder canvas here by providing a Digital Elevation Model, and I'll use the same one we used last time. And, not in demo data, it's in model data, Muvar.dem, 10 meters, we'll click OK and great, now it's ready to run, lets try running it. Good, I place on. So run Aspect, it succeeded, and now let's see, I didn't write the correct raster calculator expression, and it looks like I didn't make them. I didn't quite use the correct syntax, so let's go look at that but what's great is I don't have to rerun the rest of this. When I make changes through Master Calculator, this stuff stays ready to run, so when I want to run it again, it will just run with Master Calculator. And I think what I need to do is group these because it might be trying to use the and on 135 and Aspect raster. So let's group these so that these comparisons happen to find truth first and then it determines whether both conditions are true. So click OK and now lets click run again and it's running, it's a better symbol then last time or sign then last time that it didn't stop immediately and it's done. And now, once again, I don't have anything in ArcMap here but what I can do is click Add To Display, and it shows me right here on my map, what's going on. And I can also select Add To Display on this one to get both of them and now, let's save this and remove this specification here, let's make this empty. What if I want to be able to run this repeatedly without entering my model, just as a normal geoprocessing tool? So, now it's not ready to run again and I need to right click and make this a model parameter and that allows me to provide it like a geoprocessing tool dialogue. And I'll show you that in a moment, click Save just before I finish and let's clean up this Canvas slightly. It's just very slightly misarranged here and I'm going to click this button auto layout and it made it online. So I can see everything and we can see the two lines now between aspect raster and raster calculator because aspect raster goes into it twice. Okay so now let's go take a look at what that model parameter setting does that puts the little p over the variable and I'm going to close this and up here on DEM tools. Remember when we double clicked to open it before it said no parameters and couldn't take any inputs. Now when we want to find south facing slopes we can, as a geo processing tool here, just provide the DEM, so let's get rid of both of these. We don't need them anymore because we're going to run this again and I'm going to find the Navarro DM 10 meters, and now I can run my tool, so click OK. And it's running just like a normal geoprocessing tool, nobody even needs to know. Though it's a Model builder model, you don't have to send it only to people know how to use Model builder. It's now ready to be used just like a geoprocessing tool and I still made another common mistake here nothing showed up, right? It's because Model builder doesn't necessarily think that I care a whole lot about this data because it's model perimeter, I didn't specify where it goes. So, let's right-click the south facing slopes output here and we'll make it model perimeter, click save and now our model has two parameters here. And this one already exists, so I'm going to provide my digital innovation Model, and then I'm going to tell it where to put this output. And I'll call it nav_south_facing, and I'll click OK to run it again and it runs. And now that I have a model parameter, it behaves like a normal geoprocessing tool. And puts any outputs that weren't made model parameters in the model back in my arc map session here, just like it does in other geoprocessing tools. And I can do the same for that intermediate product too if I wanted aspect to show up. I can make it a model parameter as well but that's up to us and that's up to you whether or not you want that information coming back. And whether you want people to have to specify more as they create their models. But Add to Display only works when you're running the model within here, and then otherwise you need to make it a model parameter. So that whoever's running the model can determine where it goes, and be saved. Okay, that's it for this session about model builder. In the next session we're going to continue on, and we're going to learn even more advanced topics with using model builder to automate. But in this session we learned how to link two tools together, and how to make it into a reusable, geoprocessing tool and a new tool box. And then, now we can take this tool box, since it's just a file, and send it off to somebody to use. Okay, that's it, see you next time.