Databases join tables on shared keys: the customer ID here matches the customer ID there. GIS adds a second kind of join with no key at all, because geography itself is the key. Your points know where the incidents happened; your polygons know which district, watershed, or sales territory each place belongs to; a spatial join marries them by location, stamping each point with the attributes of the polygon it falls in, or each polygon with a summary of the points inside it. It is arguably the most useful operation in everyday GIS, and the one whose settings most quietly corrupt results when clicked on autopilot. QGIS's tool is called Join Attributes by Location, and this guide walks its decisions in the order they can hurt you.
Home / GIS and Open Map Data for Beginners
QGIS Spatial Join: Join Attributes by Location, Explained With Its Predicates

Photo: Antoni Shkraba / Pexels
Join by Location: The Checklist
Check off each step as you finish it. Your progress stays on this page.
0 of 6 complete
0% done
The Tool and Its Two Directions
Find it in the Processing Toolbox as Join Attributes by Location, also reachable from the Vector menu's data management tools. You give it a base layer, the one that will gain attributes, a join layer whose attributes travel, and a geometric predicate that defines the relationship. The direction of the join is the first decision, and it is a question about your output, not about the tool. Joining polygons to points, districts onto incidents, gives you one row per incident enriched with its district, ready for filtering and mapping by area. Joining points to polygons, through the Summary variant described below, gives you one row per district carrying counts and statistics of its incidents, ready for a choropleth. Same data, opposite products. Beginners routinely run the join in the direction the layers happen to be listed and then fight the result into shape with extra steps; professionals name the output table they want first, rows of what, carrying which new columns, and let that sentence choose the direction.
The Predicates: Eight Words That Are Not Synonyms
The predicate defines what counts as a match, and QGIS offers a family of them whose differences are exact, not stylistic. Intersects is the generous default: layers match if they share any space at all, a point on a boundary, a line crossing a corner. Within requires the base feature to lie entirely inside the join feature; a point on the polygon's edge is not within it. Contains is within read backwards, for when the base layer is the container. Touches matches only boundary contact without interior overlap, the right word for adjacency questions. Overlaps and crosses serve line and polygon relationships with specific topological meanings, and equals and disjoint complete the set for exact matches and for proving non-relationship. The practical stakes concentrate at boundaries. A point exactly on a district line intersects both districts, is within neither, and touches both. Which of those truths your analysis needs is a decision about your subject, not a default to accept. When a join produces counts that are mysteriously slightly more than the input, boundary points double-counted by intersects are the first suspect, and the fix is either a stricter predicate or a deliberate rule for boundary cases.
Join Types: One-to-One Versus One-to-Many, the Silent Multiplier
When a base feature matches several join features, the join type decides what happens, and this is the setting that silently doubles datasets. A one-to-one join keeps one output row per base feature and takes the attributes of the first match it finds, which for a point intersecting two polygons means one district wins and the other is discarded without a note. A one-to-many join emits one row per match, so that boundary point appears twice, once per district, and every downstream count of "incidents" now exceeds the number of incidents. Neither is wrong; both are answers to different questions. One-to-many is correct when the multiplicity is real, a road segment genuinely belonging to two maintenance zones should be counted by both. One-to-one is correct when the multiplicity is an artifact, the boundary case, and the analysis needs each feature counted once. The discipline is to know, before running, which situation you are in, and to verify after running with the cheapest audit in GIS: count the rows before and after. If the count changed and you cannot explain every added row by name, the join did something you did not order. Our QGIS beginner tutorial covers the layer and attribute skills this audit depends on.

The Summary Variant: Counts and Statistics per Area
The sibling tool, Join Attributes by Location (Summary), exists for the polygon-ward direction and deserves its own paragraph because it answers the most common analytical question in applied GIS: how much of this happened in each area? It takes the base polygons, finds the join features matching each by your predicate, and computes summaries of their numeric fields: count, sum, mean, median, minimum, maximum, and more, selectable per field. Districts gain an incident count and a mean severity; watersheds gain total upstream gauges and their average flow; sales territories gain summed revenue of the stores inside them. The output is a choropleth waiting for symbology, which is to say the output is the map most stakeholders actually asked for. Two cautions: the count it reports is the count of matches, so a one-to-many reality at boundaries inflates it exactly as the plain join would, and fields summarized should be summarized knowingly, since a mean of ratios and a sum of counts describe different worlds. Choose the statistic the way you chose the predicate, from the question outward.
Join by Nearest: When the Question Is Distance, Not Overlap
Some relationships are not containment at all. Which clinic is closest to each village? Which gauge station serves each field site? For those, QGIS offers Join Attributes by Nearest, which matches each base feature to the nearest join feature, optionally within a maximum distance, and can record the distance itself as a new field. It also offers the k-nearest form, matching the closest two or three, which serves questions like which two depots could cover this address. The professional cautions differ from the overlap joins. Nearest is computed in the layer's coordinate units, so a layer in degrees will happily report nonsense distances; project to a meter-based CRS first. And nearest is not the same as sensible: the closest clinic across a river with no bridge loses to the second closest on your side, a truth only a network analysis knows. Use nearest joins for screening and first approximations, and let their distance field tell you when a match is so far away it should be treated as no match at all.
The Pre-Flight Checklist That Prevents Join Disasters
Every experienced QGIS user runs the same quiet checks before trusting a spatial join, and they take two minutes. Same CRS: both layers in the same, projected coordinate system, because predicates and distances computed across mismatched systems are fiction. Valid geometry: run the geometry checker on both layers, since a self-intersecting polygon can match things it should not and miss things it should. Row counts: note the base layer's count so the after-count can be audited. Field hygiene: know which fields will collide by name, since joined attributes with duplicate names get renamed in ways that confuse later expressions. And a spot check: pick three features whose correct answer you know from the map, run the join, and read their new attributes before believing the other ten thousand rows. This is the same verification instinct this site teaches for georeferencing an image, where independent checks outrank the software's own report, and for spatial joins it is the difference between an analysis and an anecdote with a legend.
A Worked Example: Incidents Into Districts, Both Directions
Ground it in one small job. A city gives you 1,240 incident points and a layer of 12 districts, and asks two questions: which district each incident belongs to, for the case workers; and how many incidents each district carries, for the budget meeting. Direction one: base layer points, join layer districts, predicate within, one-to-one. The row count after must be 1,240, and it is, except the audit shows three points matched nothing. Inspection finds them sitting exactly on district boundaries, where within, correctly, refuses both districts. The deliberate rule chosen: those three are assigned by intersects with a manual look, and the decision is written into the project notes. Direction two: base layer districts, join layer points, Summary variant, predicate within, count plus a mean of the severity field. Twelve rows out, counts summing to 1,237, which reconciles exactly with the three boundary cases handled separately, and that reconciliation, counts that add up across both directions with every exception named, is what a finished join looks like. Neither run took a minute. The checking took ten, and the checking is the work.
Related Guides
This guide does not stand alone. The GIS and open map data guides below take up the questions it leads into:
- QGIS Join Attributes by Field Value: Attach a Table to Your Layer by a Shared Key: A field-value join is a spreadsheet lookup for maps: match rows in a table to features in a layer by a shared key, a code, a name, an ID, and the...
- QGIS LTR vs Latest: Which Version to Install, and Why Plugins, Not Features, Should Decide: QGIS ships a new version every four months, and every third one becomes the Long Term Release, supported with bug fixes for at least a year.
- QGIS Print Layout: Compose a Map Someone Can Actually Use: The map on your QGIS canvas is a working view; the map in a print layout is a finished argument, with a fixed scale, a legend that explains it,...
- QGIS Join by Attribute: The Live Joins Tab, From Shared Field to Saved Project: the non-spatial sibling join
- Network Analysis in QGIS: Shortest Paths and Service Areas on Your Own Streets: The other relationship between features: not overlap, but travel along edges.
Frequently Asked Questions
Where is the spatial join in QGIS?
In the Processing Toolbox as Join Attributes by Location, with its sibling Join Attributes by Location (Summary) beside it, and also under the Vector menu's data management tools. The Summary variant computes counts and statistics of matched features per base feature; Join Attributes by Nearest handles distance-based matching.
What is the difference between intersects and within?
Intersects matches whenever two features share any space, including a point resting exactly on a polygon's boundary. Within requires the base feature to lie entirely inside the join feature, so that same boundary point does not match. Boundary cases are where the choice shows up in your counts.
Why did my join produce more rows than I started with?
The join type was one-to-many, or your predicate matched multiple join features per base feature, commonly points on polygon boundaries matched by intersects into two areas. Decide whether the multiplicity is real for your question; if it is an artifact, tighten the predicate or use a one-to-one join, and always audit row counts before and after.
How do I count points in each polygon?
Use Join Attributes by Location (Summary) with the polygons as the base layer and the points as the join layer, choose your predicate, and select the count summary. Each polygon gains a field with the number of points it matched, ready to drive a choropleth.
Why are my nearest-join distances wrong?
Almost always because the layers are in a degree-based CRS, where distances are computed in degrees, not meters. Reproject both layers to a suitable projected CRS for your region first. Also confirm both layers share the same CRS; mismatched systems produce quietly meaningless matches.
Photo credits: Antoni Shkraba (Pexels); Antoni Shkraba (Pexels). Photos are served from this site; follow the credit to the library page for the original.