About joining the attributes of features by their location
Often, what's most interesting about a map is not the individual layers but the relationships between the features in those layers. For example, suppose you wanted to tell customers where they can find the nearest branch office of your business, or you want to compare different wildlife species with information about the habitats they live in. These types of queries can be answered with a spatial join.
A spatial join joins the attributes of two layers based on the location of the features in the layers. Like joining two tables by matching attribute values in a field, a spatial join appends the attributes of one layer to another.
You can then use the additional information to query your data in new ways. While you can also select features in one layer based on their location relative to another layer, a spatial join provides a more permanent association between the two layers because it creates a new layer containing both sets of attributes.
Performance tips for performing spatial joins
You can perform a join with either the Join Data dialog box, accessed by right-clicking a layer in ArcMap, or a geoprocessing tool. You should use the Spatial Join tool rather than the dialog box if you are performing spatial joins with large or complex datasets. The Spatial Join tool will give you better performance and reliability, and you can use the geoprocessing framework to easily automate repetitive or frequently performed joins with the tool as part of a model or script or simply by entering the parameters for the tool in the Python window. For example, you may want to perform several similar spatial joins to compare the results.
In addition, for the best results with spatial joins, it is recommended that both layers have the same coordinate system. If the layers have different coordinate systems, the following rules apply:
- The spatial join will be calculated in the target layer's (the selected layer in the table of contents) coordinate system.
- If the type of join performed involves adding a field to show the distance between joined features, the distance will be in a unit of measure associated with the target layer's coordinate system.
- If one of the layers has an unknown coordinate system and the other a defined coordinate system, an error message will appear. If both layers have an unknown coordinate system, the join will proceed and the resulting layer will have an unknown coordinate system.
- The coordinate system used to display data in ArcMap has no effect on how the data is joined. ArcMap allows data to be stored in one coordinate system and displayed in another. The analysis is always performed using the stored coordinate system.