[MUSIC] Hello everyone and welcome back. In this lecture I'm going to continue where I left off last time with the model we've been building. So far we have copied the feature class, added and calculated the defaulted for IS river field and then we loaded up the feature class as a feature layer, selected the parcels by location that intersect with the river, and set those parcels value for the IS river Field to one, to indicate that they do have the river running through them. Next up, I think what we need to do is add another field for whether it's on the correct side of the river. So, I'm going to do that way back here before we load it as a feature layer. And while we could do it in line with the rest of this, let's show off some branching in ModelBuilder and learn a few other concepts while we do it. So, I'm going to select add field and I'm going to hold control and select the field calculation here and I'm going to hit CTRL+C on my keyboard and CTRL+V to paste them. And we're going to duplicate those, and it's going to branch off of this initial copied features. And then run that same operation again. So now let's tweak them to actually reflect what we want to add. So in this case, the Add Field isn't is_river anymore, it's is_on_correct_side_of_river. And this is basically setting up the end goal for this model, which is this field that has, whether or not it's on the correct_side_of_river, as zero or one to indicate whether the parcel's on the same side of the river as the town boundary. So I'll click okay, that's fine now, and then I'll call, let's rename this parcels_with_correct_side. Just so we know a little more that's going on, and let's even rename this this time, Add Correct Side Field and this one can be Add River Fields, that way we know which one's which when we go to modify them later. And this one will be Calculate Default Correct Side Value. And now we can actually look at this at a glance and know what our model is doing. And once again even though I've renamed these, they're still the same tools underneath the surface. And I'll call this parcels_with_default_side_value. So, I could run these now and that underlined feature class would get the values attached. But, now that we've branched out here, how does ModelBuilder know how to run this? Well, by default it's pretty smart and figures out kind of where to go, but, generally speaking, if we know that this needs to be available before sometime in the future, we should use the prerequisite option. Now, in this case I think we want to make it available before we make a feature layer, because we want to make sure that this field is available when it's a feature layer. So I'm going to use the connect tool and click and drag from the output of the calculate value tool here to the Make Feature Layer. And in this case I'm just going to call it a precondition which says that these need to run before this. And ModelBuilder will choose whether it runs the rest of this, or whether it runs this and then this, but regardless, all of this will run before it runs Make Feature Layer, and everything after it. And now, let's just run the whole thing and watch the branching in action. So, let's validate it. No warnings. Great. If it doesn't tell us anything, we're good. And if it does, it'll pop up a dialogue telling us what's wrong. And now let's click run. And just watch it in action here. So, it's running copy features and then it's adding the river fields and default river value. And then it's now adding correct side field, correct side value, and now it's doing make feature layer and everything after it. So it did run all of it. We could see it by the shadows here. And it didn't highlight it in red, and I'm not totally sure why. But the dialog box showed us exactly what was running when. And we are able to see that it ran all of this before it then proceeded. Okay, so now we have the bulk of our setup done. We've done kind of our basic infrastructure setup. We've added a couple of fields and set the default values, then we figured out which parcels have rivers in them. Now we can continue on with our analysis. So, I have a sort of problem here in that I've already added the IS river field and so I want to now dissolve the parcels layer based upon the IS river field. But I have a selection active on the IS river field for the rivers layer and I personally don't know how to create a new selection or clear the selection actually. I don't know how clear the selection in ModelBuilder but I do know how to switch it to something that we can use. So, I'm going to copy select layer by location just so I can use it here, again. And then I'm going to actually make the inputs here as both the input and the selecting layer, because what I'm going to do means that the inputs don't really matter except the Input Feature Layer. And I'm going to select switch selection. And I suspect we could probably do something like this with the Input Feature Layer in the selecting feature has been the same. And calling it new selection or something like that and we might get what we want, but we're going to switch selections. So now, all of the non river polygons will be selected and that's really what we want. We want to only dissolve those anyway. So, we're going to get what we really want out of this so I'll click okay. And what it'll do is it's going to select the reverse, or select the parcels that intersect with the river, calculate the value for those parcels to be one, and then it's going to select all the non river parcels which we can then use in our dissolve step. So, let's go find our dissolve tool here, and it's under generalization and dissolve. And, before we do, let's call this switch selection to Non-River Parcels just to continue our documentation here, and we're bringing this to, Non-River Parcels here, and then we can feed that into Dissolve as Input Features. And what we still need to select with Dissolve is the field that it's going to dissolve on. And what we want to dissolve on in this case is river. Notice that is_on_correct_side_of_river shows up, it knows that that's created first, and that it will be on this feature class. So that's really handy, we could use that here if we needed to, and we will coming up. So is_river is what we're dissolving on where we want distinct polygons for each part of is_river. And then what we really don't want is we don't want to create multi part features, right? Because what I'm trying to get is separate polygons on each side of the river. So if it created multi part features for all of the values that were zero I'd get one big polygon for both sides of the river. Instead I want one big polygon on the left side of the river and one big polygon on the right side of the river that are separate polygons. So I'm going to uncheck that and click okay so the output of this will give us each of those polygons. But we still, we still don't necessarily have the, we don't know which one's correct yet. So we need another Select By Location so I'm going to once again take this Select By Location and copy it and move it out here, and let's rearrange all this stuff. And we'll take this one over here again. And what we really want is, this dissolved layer here is going to be what we want to make a selection on, and then we're going to select with our with some data that we don't yet have on the canvas the town boundary. So let's add town boundary to the canvas and make it the selecting features because what we're going to do is select the dissolve polygon that intersects with the town boundary. But remember I need to make this a feature layer before I do because it writes out the dissolve polygons to the hard drive and I might want to necessarily make this name different so that again that it doesn't collide with some other name, but for now we can leave it as is. In fact, the validate button will warn us if we have multiple things riding up to the same name. And, I need to make a feature layer. So, let's copy this over here. And move it here. And we'll make this the input here, as the Input Features, and remove this other redundant precondition because that was just because I copied it. And now once I have the feature layer, I can feed this feature layer in as the input feature layer. So the town boundary's the selecting features which doesn't have to be a feature layer necessarily. That could be a feature cost but the layer to make the selection on has to be a feature layer. So let's name these. So let's rename this to Select Correct Side. And we'll rename this Correct Side Polygon. Because that's what we selected. And once again we can Auto Layout. And see a little bit of how ModelBuilder's choosing to arrange our layout here. And, before we proceed, let's again step through our model and see everything in action. We've already seen this first part up to here. But, let's do what we did before where we looked at the model and actually each step so that we really understand what's going on. And so, let's validate it to clear out everything. And it's telling me I have duplicate data set name for a variable. So the validate button helped because it reminded me that when I copied that Make Feature Layer, I didn't change the name here. It says pacels layer still and in fact it is not the parcels layer, this is the dissolved_polygon_layer. And I should rename this to result two. So, the validation button can help us prevent outselves from making mistakes. So, let's validate again. We're clear. And I'm going to select all of the stuff that we already went through and we understand what the Adding Correct Side stuff does because we watched this in action too, so we're going to go through all that Calculate Default River Value, as just one big one step here, and so we'll watch it in action. Great, okay. So, that's all done up to here. And, if we right click on the parcels layer, let's, so, since I've already had add to display check, it didn't do it. It unchecked it. Then when I click add to display again, it shows up. So, we still have the rivers, polygon selected here. So now let's run the Switch Selection. And it's a quick operation and if I zoom out or do something to change this by like hitting a file, I can see that it did change it. And in fact these polygons in the middle here are not selected. So we're doing quite well. And, now, let's run our next step. The dissolve of those selected polygons. So, that's running. And we don't see anything because we didn't have Add to Display checked. So, I'm going to click Add to Display and we get two polygons here. So, let's turn off parcels_layer so the selection goes away and we can see that we got some separate polygons here. And if I open the attribute table, I have two polygons. So I have the one on the left side and the one on the right side. So we're making progress here. And let's deselect so we leave everything the way it was and don't mess with our model. And expand our model back up. And then we'll run the Make Feature a Layer again, quick and easy. And then we'll Run the Select of the Correct Side here. Since that used the town boundary to select which polygon here was on the right side. And we don't see it because we added the dissolve feature class, not the dissolve feature layer. So let's add this to our display. And in fact we can see that is has a selection active on the correct side on the river, so our algorithm works. We just proved that the algorithm to find the right side of the river does work, but we still need to use this selected polygon to mark the parcels on this side of the river as being on the correct side. So think about how we might do that still and we'll save that for the next video. So in this video we added in quite a few steps in terms of actually finding the right side of the river. So we dissolved the parcels after we marked which ones were on which side of the river and then we found which one is on the right side of the river by selecting by location with the town boundary and the dissolved polygons here. In the process, we also added this stuff at the beginning where we made our model branch, but still controlled the flow so that it didn't proceed to Make Feature Layer until after all of this had been attached. In the next video, we will finish our model off by selecting the correct parcels using this new polygon here and then calculating the field again. See you next time.