Lesson 6: Simple spatial analysis
Complexity: intermediate
Outcome: create a teaching management-area polygon, select observations inside it, create a 100 m buffer, clip and intersect the buffer, then save every result in the course GeoPackage.
Before you begin
Complete Lessons 4 and 5 first.
You need:
03_project/qgis-course.qgz02_working/course.gpkgobservationswithOBS-001,OBS-002andOBS-003
The management polygon in this lesson is deliberately synthetic. It exists only to teach the tools. Do not present it as a real rohe, management boundary, catchment or area of authority.
The question
You will answer:
Which teaching observations fall inside a teaching management area, and what does a 100 metre area around those observations look like when constrained to that polygon?
1. Open the course project
- Start QGIS.
- Choose Project → Open….
- Open
03_project/qgis-course.qgz. - Confirm the lower-right corner shows
EPSG:2193. - Find
observationsin the Layers panel. - Right-click
observations. - Choose Open Attribute Table.
- Confirm three rows exist with IDs
OBS-001,OBS-002,OBS-003. - Close the table.
- Right-click
observationsagain. - Choose Zoom to Layer(s).
- Save the project.
You should now see
The three teaching observation points in the map canvas.
2. Create the management-area polygon layer
- Choose Layer → Create Layer → New GeoPackage Layer….
- Beside Database, click the browse button.
- Browse to
qgis-course/02_working. - Select
course.gpkg. - Click Open.
- Set Table name to:
teaching_management_area
- Set Geometry type to Polygon.
- Set CRS to NZGD2000 / New Zealand Transverse Mercator 2000 – EPSG:2193.
- Add a Text field named
area_idwith a length such as 20. - Click Add to Fields List.
- Add a Text field named
purposewith a length such as 100. - Click Add to Fields List.
- Confirm both fields appear in the field list.
- Click OK.
- Confirm
teaching_management_areaappears in the Layers panel. - Save the project.
3. Draw one polygon around some, but not all, observations
- Click
teaching_management_areain the Layers panel. - If the Digitizing toolbar is missing, choose View → Toolbars → Digitizing Toolbar.
- Click Toggle Editing.
- Click Add Polygon Feature.
- In the map canvas, click once to place the first polygon vertex.
- Move the mouse and click again to place the second vertex.
- Continue clicking around a shape that contains at least one observation point but leaves at least one observation outside it.
- You do not need to click the first vertex again to close the polygon.
- Right-click once when you have placed the final vertex.
- The attribute form opens.
- Enter:
area_id: AREA-001
purpose: teaching spatial analysis
- Click OK.
- Click Save Layer Edits.
- Click Toggle Editing to turn editing off.
- If QGIS asks whether to save changes, choose Save.
- Save the QGIS project.
You should now see
One polygon and three observation points, with at least one point inside and one point outside the polygon.
If the polygon covers all three or none of them, edit it now rather than continuing with a poor test case.
4. Adjust the polygon if needed
Only do this if you need to change its shape.
- Select
teaching_management_area. - Click Toggle Editing.
- Choose the Vertex Tool from the Digitizing toolbar.
- Click the polygon.
- Drag one or more vertices until the polygon contains some but not all observation points.
- Click Save Layer Edits.
- Turn editing off.
- Save the project.
5. Open the Processing Toolbox
- Choose Processing → Toolbox.
- The Processing Toolbox should open as a panel.
- If you cannot see it, choose View → Panels → Processing Toolbox.
- Click in the toolbox search box.
You will use this panel repeatedly in the rest of the course.
6. Select observations inside the polygon
- In the Processing Toolbox search box type:
Select by location
- Double-click Select by location.
- Set Select features from to
observations. - In the geometric predicate list, tick are within and leave unrelated predicates unticked.
- Set By comparing to the features from to
teaching_management_area. - Leave the selection method at its normal option to create a new selection.
- Click Run.
- Wait for the operation to finish.
- Click Close.
- Look at the map. Selected observation points should use the QGIS selection highlight.
- Right-click
observationsand open its attribute table. - Use Show Selected Features if necessary to see only the selected rows.
- Count the selected records.
- Write the count down temporarily or add it to
03_project/README.md. - Close the attribute table.
You should now see
At least one but fewer than three selected observation points.
If zero or all three are selected, adjust the polygon and rerun the selection.
7. Export only the selected observations
- Keep the intended observation selection active.
- Right-click
observations. - Choose Export → Save Selected Features As….
- Set Format to GeoPackage.
- Beside File name, browse to
02_working/course.gpkg. - Set Layer name to:
observations_in_management_area
- Set the output CRS to EPSG:2193.
- Confirm QGIS is saving only selected features. Because you used Save Selected Features As, this should already be the case.
- Leave Add saved file to map enabled.
- Click OK.
- Wait for the new layer to appear.
- Right-click
observations_in_management_area. - Open its attribute table.
- Confirm its row count matches the selection count from step 6.
- Close the table.
- Save the project.
8. Clear the old selection
- Choose Edit → Select → Deselect Features from All Layers, or use the Deselect Features from All Layers toolbar button if visible.
- Confirm the selection highlight disappears from the original
observationslayer.
This prevents an old selection from accidentally affecting a later operation.
9. Create a 100 metre buffer
- In Processing Toolbox search for:
Buffer
- Double-click the standard Buffer algorithm.
- Set Input layer to
observations_in_management_area. - Set Distance to:
100
- Because the input CRS is EPSG:2193, the distance is in metres.
- Leave segment/end-cap/join settings at their defaults for this teaching exercise.
- Leave Dissolve result off so each input point retains its own buffer feature.
- At the output destination, choose Save to GeoPackage….
- Select
02_working/course.gpkg. - Set output layer name to:
observation_buffer_100m
- Click Run.
- Wait for completion.
- Click Close.
- Save the project.
You should now see
Circular buffer polygons around the selected teaching observations.
10. Check that 100 really means 100 metres
- Choose View → Toolbars → Attributes Toolbar if you cannot find a measurement tool.
- Choose Measure Line from the measurement tools.
- Click approximately at the centre point of one observation.
- Click at the outer edge of its buffer.
- Right-click to finish the measurement if required.
- The distance should be approximately 100 m.
- Close the measurement window.
If the buffer is many kilometres wide or almost invisible, check the input CRS and distance before continuing.
11. Clip the buffers to the management area
- In Processing Toolbox search for:
Clip
- Double-click Clip.
- Set Input layer to
observation_buffer_100m. - Set Overlay layer to
teaching_management_area. - Set the output destination to Save to GeoPackage….
- Select
02_working/course.gpkg. - Set the output layer name to:
buffer_clipped_to_management_area
- Click Run.
- Wait for completion.
- Click Close.
- Save the project.
Turn the original buffer and clipped buffer on and off. Any part of a buffer outside the management polygon should be absent from the clipped result.
12. Run Intersection
- In Processing Toolbox search for:
Intersection
- Double-click Intersection.
- Set Input layer to
observation_buffer_100m. - Set Overlay layer to
teaching_management_area. - Leave the input/overlay field lists at their defaults so attributes from both sources are available for comparison.
- Set output destination to Save to GeoPackage….
- Select
02_working/course.gpkg. - Set layer name to:
buffer_management_intersection
- Click Run.
- Wait for completion.
- Click Close.
- Save the project.
13. Compare Clip and Intersection attributes
- Right-click
buffer_clipped_to_management_area. - Choose Open Attribute Table.
- Note which fields are present.
- Close it.
- Right-click
buffer_management_intersection. - Open its attribute table.
- Look for fields originating from
teaching_management_area, such asarea_idorpurpose, as well as the original observation-related fields. - Close the table.
The geometry may look similar, but Intersection is useful when you want the overlay attributes carried into the result.
14. Open Processing history
- Choose Processing → History… or open the Processing history/log through the Processing menu available in your installation.
- Find the recent entries for:
- Select by location
- Buffer
- Clip
- Intersection
- Click each entry and inspect its saved parameters or command information.
- Confirm the buffer distance was
100and the intended input layers were used.
Processing history is one of the easiest ways to answer “what exactly did I run?” after the map result is already on screen.
15. Record the method
Open 03_project/README.md and add:
Lesson 6 spatial analysis
CRS: EPSG:2193
Selection: observations within teaching_management_area
Selected observation count: [your count]
Selected output: course.gpkg → observations_in_management_area
Buffer: 100 metres
Buffer output: course.gpkg → observation_buffer_100m
Clip overlay: teaching_management_area
Clip output: course.gpkg → buffer_clipped_to_management_area
Intersection output: course.gpkg → buffer_management_intersection
Note: teaching_management_area is synthetic course data, not a real management boundary.
Save the README and QGIS project.
16. Confirm the GeoPackage contents
- In the Browser panel find
02_working/course.gpkg. - Expand it.
- Confirm these layers exist:
observations
observations_in_management_area
teaching_management_area
observation_buffer_100m
buffer_clipped_to_management_area
buffer_management_intersection
- If a layer is missing, return to the corresponding step and rerun it with a saved GeoPackage output rather than a temporary output.
17. Reopen the project
- Save the project.
- Close it.
- Reopen
03_project/qgis-course.qgz. - Confirm the five derived/teaching analysis layers still load.
- Open
observations_in_management_areaand confirm the feature count is still the expected count.
Verify before moving on
You should be able to show:
- a synthetic management polygon containing some but not all observations
- the original
observationslayer unchanged - selected observations saved as a separate layer
- a 100 m buffer in EPSG:2193
- the clipped buffer result
- the intersection result
- fields from the overlay in the Intersection result
- Processing history showing the operations you ran
- the method written into
README.md
Common problems
No observations are selected
Your polygon does not contain the points under the within predicate. Edit the polygon, save it and rerun Select by location.
A point lies exactly on the polygon edge and is not selected
within and intersects are different spatial relationships. Rerun Select by location using intersect to compare the behaviour.
The buffer is enormous or tiny
Right-click the input layer → Properties → Information and confirm EPSG:2193. Confirm the buffer distance is 100, not 100000, 0.1 or another unit assumption.
The result disappeared when I reopened QGIS
You probably left the algorithm output as Create Temporary Layer. Rerun the operation and use Save to GeoPackage… with the exact output names in this lesson.
Clip and Intersection look identical
Open their attribute tables. The geometry can be similar, but Intersection can retain overlay attributes that a simple Clip result does not provide in the same way.
Processing Toolbox is missing
Choose View → Panels → Processing Toolbox.
Next: Lesson 7: Georeference a historical image.
Test basis: QGIS 3.44 LTR. Last reviewed: 4 September 2026