Sometimes we want to be able to join data from one dataset to another not based on the attributes in their table, but based on the geography of the two of them, and that's done using a spacial join. So, spacial join joins attributes based on location not on columns and tables which you may have seen in the joined by an attribute table section. So, here we have some schools and some census tracks and this is a very common scenario. Is that if we look at the attribute table for schools, all we have in there are names and in the census track data we have median income, and what I would like to do this is like I said a typical thing is I'd like to be able to transfer the median income data for each census track to the school points for the polygon that the school is inside of. So, in other words, we're going to get the software to ask the question here's a school point which census tract polygon is that school point inside of and then take the data from that census track polygon and transfer it to the point. Totally based on geography. In other words, the spatial relationships between the two feature classes. So, here's the schools and the median income quantiles, and our goal is to transfer the income data to schools based on location. So, here's our two inputs attribute tables and you'll notice that there's nothing in common in terms of a primary key, foreign key nothing like that. It's totally going to be done based on location. So, if we just right-click on our destination that we want the data to be put into. In this case that would be the school data, and we can say what do you want to do? We want to join data from another layer based on spatial location. We're going to use household income here and this is the important thing here is the way that we're defining that is by saying each point will be given all the attributes of the polygon that it falls inside. So, that each school that falls inside a polygon that data from that polygon will be applied to that school, and notice that unlike with joining tables by attributes, with a spatial join you are actually creating a new feature class. In this case, it's going to go into a new or into an existing file geodatabase. So, this is my result. That's all there is to it. Is that I joined the two things together and what I did was I actually color-coded the points to match the color scheme I used for the polygons just I hope emphasize and make it clear that I've taken the data from the census tract polygons and it's now stored inside the new dataset that's based on the school points. Here's the attribute table for that. So, we have the name of each school that we already had in the original school data, but we also have the census tract ID number and the median income data from the polygons that have been transferred over based on spatial location to our new dataset. That's essentially it. It's simple but powerful tool because now you're able to join datasets that don't have something in common in terms of attributes or fields or primary keys or whatever. You can do it strictly based on the geography which often after all is the case where we want to ask a spatial geographic question and say where do these things interact in space? Can we associate data from one to the other based on that. Spatial joins are not just limited to points inside polygons. There's lots of combinations of features that we can use. So, I just wanted to show you another example here. In this case I'm going to do a spatial join of points to points. So, I have schools and libraries and maybe we're interested in knowing for example how many schools are within or closer to one library than to any other library. So, this might be the type of thing where if you operate a library, you managed it, you might be wanting to know well how many schools are closest to this library and that we would be responsible for or might want to interact with in some way or have programs with those schools. So, this would be a way of being able to work through that question. So, here's our input attribute tables. We have school names in one dataset and we have library names in another dataset. If we do a spatial join, we're going to join libraries to the schools and in this case, I'm going to specify that each point will be given all the attributes of the point in the layer being joined that is closest to it. So, this is a spatial join, but it's being done in a slightly different way as what it's basically going to do is ask the question well, how many of those points are closest to this point? If they are then we'll act based on that. So, now we have school with the closest library. So, we could ask that question and say which library is closest to which school, and so, now we have the school name. So, for example Highview Public School, and then we have the library name, and so, Black Creek is the library that's closest to that school. Not only that, but there's a side bonus or an extra. Is it actually automatically calculates the distance between the two. So, we know for a fact that Black Creek Library is 1,070 meters away from Highview Public School, and it does that for all of them. So, how does it know that? How does it know which points are closest to which points? Well. It's based on using Thiessen polygons which is actually a tool called Euclidean allocation in the software, and this is another one of these cases where you don't see it doing this. You don't have to tell it to do this. I'm just showing you how it works conceptually so you know what's going on behind the scenes. So, if I did a Euclidean allocation and you can do this or you can use this tool if you want. I'm just showing you how this all works. Is that essentially I'm generating Thiessen polygons around each of the libraries, and I just created this by taking those Thiessen polygons, converting them from raster to vector just to make them a little easier to work with so I can make them hollow, and so, if we zoom in a little bit here, you'll see that we now have a Thiessen polygon that indicates for example this one here. This polygon indicates that anything that's inside this polygon is closer to this library than to any other library, and so, all of these schools fall inside that Thiessen polygon and therefore they must be closest to that library, and like I said, you don't have to do this manually, but this is how the software is identifying which school points are closest to which library point and that's what is basing the spacial join on. If we want we can choose a different option. So, here I'm going to join schools and I'm going to select the option. Each point will be given a summary of the numeric attributes of the points in the layer being joined to that that are closest to it. So, let's see how that works. So, this gives me a slightly different result. What this is telling me? Is that this is the library name. So, this is an output that's the libraries. So, Beaches for example is the name of a library and this is providing me with a count of how many schools are closer to that library than to any other library, and so, the next one Bendale for example actually has 13 schools that's a lot that are closer to that library than to any other library. So, I won't go through every single option in spatial join, but I do think it's useful to see some of these things because this really gets to me anyway. This is getting to the heart of what spatial analysis can be. Is you're asking geographic questions about, is this thing inside that thing? Or what's closest? How far away are they? Can I associate data from one to the other? Or how many of these things are closest to that thing? So, there's lots of ways to frame those questions, but the spatial join tool is a great way of using or applying those questions. I just wanted to show you if you wanted to visualize the result of that count of the schools and libraries, what I'm doing here is I'm going to create a proportional symbol map based on those counts and I'm just using the library symbol here. So, that's going to be the minimum value that is going to be the maximum value, and now the size of the library symbol reflects the number of schools that are closest to each of those. So, the bigger the library's symbol the more schools potentially that that library may service based on the fact that those schools are closest to it. So, it's just a nice way I think of wrapping up here is if you were say working for some organization that manages all of these libraries or is in charge of outreach programs to the schools, this would be a great way of being able to visualize the relationships between libraries and schools and you could do it in terms of which ones are closest or how many of them are there, and so, this is a nice proportional symbol map just to illustrate that.