Skip to content
← Back to Spatial Analysis
spatial-analysisIntermediate· 6 min read

Vector Overlay and Proximity Analysis: Clip, Intersect, Buffer and Join

How overlay tools combine two vector layers, how buffers and nearest-feature joins measure closeness, and what to check so the results are right.

What is overlay?

Overlay means placing two layers on top of each other and computing something from where they coincide. The result is a new layer, with new geometry and usually attributes from one or both inputs.

Most real questions need it. Which parts of a park lie within 500 metres of a lake? How many hospitals fall in each ward? What land is in a floodplain and is also built up?

The overlay tools

Think of two layers: an input layer and an overlay layer.

ToolResult
ClipThe input features cut to the shape of the overlay. Attributes come from the input only
IntersectionThe parts where both layers overlap, with attributes from both
UnionEverything from both layers, split where they overlap, with attributes from both
DifferenceThe parts of the input that the overlay does not cover
Symmetric differenceThe parts covered by only one of the two layers
DissolveMerges features of one layer that share a value

Difference depends on the order of the layers. Parks minus lakes is a different result from lakes minus parks. Check which layer you chose as the input.

Buffers and proximity

A buffer is a zone drawn at a set distance around features. A 2 km buffer around a hospital is the area within 2 km of it, measured in a straight line.

The distance is read in the units of the layer's coordinate system. In a geographic CRS such as EPSG:4326 the unit is degrees, so a buffer of "2000" would be absurd. Reproject to a projected CRS such as UTM first, and the same number means 2,000 metres.

Other proximity tools:

  • Multi-ring buffers draw several distances at once, for example 500 m, 1 km and 2 km.
  • Join by nearest attaches to each feature the attributes of the closest feature in another layer, and records the distance.
  • A distance matrix lists the straight-line distance between every pair of points in two sets.
  • Nearest neighbour analysis summarises how close points are to each other, which is covered in the spatial statistics note.

All of these measure straight lines. For distance along roads, use network analysis instead.

Points in polygons

Counting points inside polygons turns a point layer into a measure per area. A grid of 2 km cells over a city, with a count of hospitals in each cell, shows where they cluster and where there are none. The count depends on the cell size and on where the grid starts, so try a second size before you trust a pattern.

Join by location

A join by location copies attributes from one layer to another based on where they are. You can attach a ward name to every hospital, or take the mean of an attribute for all points inside each polygon.

Example: parks near lakes

In the QGIS tutorial, lakes in central Bengaluru are buffered by 500 metres and dissolved into one zone. Difference with the parks layer gives the park area farther than 500 metres from a lake. Intersection gives the park area within 500 metres. In the tutorial's study window, the figures were about 431 hectares within the zone and 625 hectares beyond it. Your numbers will vary with the window and the date of the OpenStreetMap data.

Chaining tools into a model

A sequence of tools you run again and again can be saved as a model, in which the output of one tool becomes the input of the next. In QGIS, the Graphical Modeler draws this as boxes and arrows. You define the inputs, such as a layer and a distance, add the tools, and name the outputs.

A model can be run again with a different distance or layer, run over many layers in a batch, and exported as a Python script. It also records the workflow, which helps when you need to explain or repeat it. A model that buffers hospitals and extracts the places inside the buffer is a typical example. Name the inputs clearly, test the model on a small layer first, and remember that a buffer distance still depends on the units of the layer's coordinate system.

Checks before you trust a result

  1. Check that both layers use the same projected CRS.
  2. Run a validity check. Invalid polygons, such as ones that cross themselves, are the most common reason an overlay tool fails or returns odd shapes.
  3. Look at the result on a map, not only in a table.
  4. Compare totals. The area of the pieces from an intersection and a difference should add up to the original.

Common mistakes

  • Buffering in degrees.
  • Swapping input and overlay in difference.
  • Adding areas after a union without noticing that overlapping features were split.
  • Skipping the validity check.
  • Reading a count from a grid without testing a second cell size.
  • Using straight-line distance when the question is about travel.

Glossary

TermMeaning
OverlayCombining two layers by where their features coincide
BufferA zone at a fixed distance around a feature
DissolveMerging features that share a value into one
Geometry validityWhether a polygon follows the rules, with no self crossings
Join by locationCopying attributes between layers by position
Projected CRSA coordinate system in metres or feet, suitable for distance

Practise it

The tutorial Vector geoprocessing and Model Builder runs these tools on OpenStreetMap parks, lakes and hospitals, and chains them into a reusable model.

Test yourself

1. Why must you reproject before buffering a layer in degrees?

The buffer distance uses the layer's units. In degrees, a distance of 2000 is meaningless. A projected CRS gives distances in metres.

2. What is the difference between clip and intersection?

Clip keeps the input attributes only. Intersection keeps attributes from both layers.

3. What can go wrong if a polygon is invalid?

Overlay tools can fail, or return missing or distorted shapes. Run a validity check and repair the geometry first.

Quick quiz

1. Which tool gives the parts of the input layer that the overlay layer does not cover?
2. A buffer of 500 is drawn on a layer in EPSG:4326. What are the units?
3. Which tool measures closeness along roads?
0 of 3 answered

Key takeaways