Spatial Joins

A spatial join allows you to summarize data in one vector layer based on its spatial relationship(s) to the features in a different layer.

Included in this tutorial:

  • Accessing the Join Attributes by Location (summary) tool

  • Tool Parameters and Options 

  • Example: Point-to-Polygon Spatial Join, with aggregation and sum

  • More Spatial Joins

Software version in examples: QGIS-LTR 3.40.5-Bratislava

Tutorial Data: The tutorial includes demonstration with sample data available here.

Credits: Sally Kaye and L. Meisterlin (2025)

This tutorial demonstrates a classic point-to-polygon spatial join wherein point features are aggregated and summarized based on the polygons they intersect using the Join Attributes by Location (summary) tool. Note that the same process applies to other geometry types and other spatial relationships. 

Tools for other types of joins using spatial relationships between layers are described at the end of this tutorial.

 

Accessing the Join Attributes by Location (summary) tool

The Join Attributes by Location (Summary) tool can be found in the Processing Toolbox under Vector General or by using the search bar at the top of the toolbox. 

accessing the Join Attributes by Location (summary) tool in the processing toolbox


Tool Parameters & Options

This section includes an overview of the parameters and options of the Join Attributes by Location (Summary) tool.

Input layers

  • Join to features in (target layer): the layer within which the join features (and their attributes) will be aggregated and summarized. In the classic points-to-polygons spatial join, the polygons are the features to be joined to.

  • By comparing to (join layer): the layer with features that will be aggregated. In the classic points-to-polygons spatial join, the points are the these features.

input layer parameters

Specifying the Join Relationship

The type of spatial join is determined by the relationship between the target and join layer.

Using the checkboxes between the input layers, choose to join to features in the target layer where the features intersect, contain, equal, touch, overlap, are within, or cross features in the join layer. 

join relationship options

Attribute Field and Summarizing Options

A spatial join will aggregate multiple join features (e.g., points) sharing the same relationship to a target feature (e.g., a polygon). During that operation, attribute values associated with the aggregated features can be summarized. 

First, we choose which fields in the aggregated layer’s attributes to summarize; then we choose which summary statistics to calculate. 

  • Click the three-dot button next to fields to summarize to choose which fields from the join (point) layer’s attributes to summarize in the output.

  • Click the three-dot button next to summaries to calculate to view options for statistics to calculate for each field chosen in the previous step (for example, count, range, sum, mean, median, and standard deviation).

NOTE: Both parameters are optional. If no fields or statistics are specified, all will be summarized/calculated. 

accessing field and summary options

Output Options

The Join Attributes by Location (summary) tool creates a new Joined Layer with the geometry and original attributes of the target layer and additional joined attributes from the join layer. By default, the tool generates a temporary layer and adds it to the current project. You can also choose to create a new dataset file by clicking the three-dot button to the right and specifying a name and location for saving the new file.

There is also an option to discard records which could not be joined. If this box is checked, the output will only include the target features (polygons) that have a spatial “match” with the join features (points).

output options


Example: Point-to-Polygon Spatial Join, with aggregation and sum

The following example demonstrates a point-to-polygon spatial join, using the Join Attributes by Location (summary) tool. In the demonstration we… 

  • Join all intersecting points from the “Points1_Table1_join” layer to the “Tracts_prj” polygon layer. 

  • Specify the fields from the join layer to summarize in the output feature class: The output will include the sum and count of the values in the point layer’s “int_sm” attribute field from the features that intersect each polygon.

  • Do not discard records which could not be joined. This means that our outputs should include each of the polygon features included in the input layer, regardless of whether it intersects any points. 

  • Specify a temporary layer as the output. (We maintain the default setting.)

The demonstration also examines the result

  • Output Geometry: We note that the geometry of the output feature class is identical to the input polygon layer. 

  • Output Attributes: The output feature class attribute field names reflect the summarized field name from the input point layer and the selected summary parameter. In this example, our output feature class attribute table contains all fields from the target layer as well as a count field (called “int_sm_count”) that notes how many join features (points) intersected each polygon and a field (“int_sm_sum”) containing the sum of the “int_sm” values of all points intersecting each polygon.

demonstrating a point-to-polygon spatial join and its results


More Spatial Joins

In this tutorial, we demonstrated the Join Attributes by Location (summary) tool. Other tools are also available for executing spatial joins, using different join types or spatial relationships. 

Join Attributes by Location provides the same spatial relationship options as Join Attributes by Location (summary) but does not summarize fields; it has three join type options to transfer attributes to matching features. 

Join Attributes by Nearest joins attributes from features in one layer to the nearest feature(s) in another layer (in this tool, the spatial relationship is distance). A maximum distance can also be specified.

join type options in the Join Attributes by Location tool

the Join Attributes by Nearest dialogue box

 
Next
Next

Table Joins