Skip to main content

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.qgz
  • 02_working/course.gpkg
  • observations with OBS-001, OBS-002 and OBS-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

  1. Start QGIS.
  2. Choose Project → Open….
  3. Open 03_project/qgis-course.qgz.
  4. Confirm the lower-right corner shows EPSG:2193.
  5. Find observations in the Layers panel.
  6. Right-click observations.
  7. Choose Open Attribute Table.
  8. Confirm three rows exist with IDs OBS-001, OBS-002, OBS-003.
  9. Close the table.
  10. Right-click observations again.
  11. Choose Zoom to Layer(s).
  12. Save the project.

You should now see

The three teaching observation points in the map canvas.

2. Create the management-area polygon layer

  1. Choose Layer → Create Layer → New GeoPackage Layer….
  2. Beside Database, click the browse button.
  3. Browse to qgis-course/02_working.
  4. Select course.gpkg.
  5. Click Open.
  6. Set Table name to:
teaching_management_area
  1. Set Geometry type to Polygon.
  2. Set CRS to NZGD2000 / New Zealand Transverse Mercator 2000 – EPSG:2193.
  3. Add a Text field named area_id with a length such as 20.
  4. Click Add to Fields List.
  5. Add a Text field named purpose with a length such as 100.
  6. Click Add to Fields List.
  7. Confirm both fields appear in the field list.
  8. Click OK.
  9. Confirm teaching_management_area appears in the Layers panel.
  10. Save the project.

3. Draw one polygon around some, but not all, observations

  1. Click teaching_management_area in the Layers panel.
  2. If the Digitizing toolbar is missing, choose View → Toolbars → Digitizing Toolbar.
  3. Click Toggle Editing.
  4. Click Add Polygon Feature.
  5. In the map canvas, click once to place the first polygon vertex.
  6. Move the mouse and click again to place the second vertex.
  7. Continue clicking around a shape that contains at least one observation point but leaves at least one observation outside it.
  8. You do not need to click the first vertex again to close the polygon.
  9. Right-click once when you have placed the final vertex.
  10. The attribute form opens.
  11. Enter:
area_id: AREA-001
purpose: teaching spatial analysis
  1. Click OK.
  2. Click Save Layer Edits.
  3. Click Toggle Editing to turn editing off.
  4. If QGIS asks whether to save changes, choose Save.
  5. 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.

  1. Select teaching_management_area.
  2. Click Toggle Editing.
  3. Choose the Vertex Tool from the Digitizing toolbar.
  4. Click the polygon.
  5. Drag one or more vertices until the polygon contains some but not all observation points.
  6. Click Save Layer Edits.
  7. Turn editing off.
  8. Save the project.

5. Open the Processing Toolbox

  1. Choose Processing → Toolbox.
  2. The Processing Toolbox should open as a panel.
  3. If you cannot see it, choose View → Panels → Processing Toolbox.
  4. Click in the toolbox search box.

You will use this panel repeatedly in the rest of the course.

6. Select observations inside the polygon

  1. In the Processing Toolbox search box type:
Select by location
  1. Double-click Select by location.
  2. Set Select features from to observations.
  3. In the geometric predicate list, tick are within and leave unrelated predicates unticked.
  4. Set By comparing to the features from to teaching_management_area.
  5. Leave the selection method at its normal option to create a new selection.
  6. Click Run.
  7. Wait for the operation to finish.
  8. Click Close.
  9. Look at the map. Selected observation points should use the QGIS selection highlight.
  10. Right-click observations and open its attribute table.
  11. Use Show Selected Features if necessary to see only the selected rows.
  12. Count the selected records.
  13. Write the count down temporarily or add it to 03_project/README.md.
  14. 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

  1. Keep the intended observation selection active.
  2. Right-click observations.
  3. Choose Export → Save Selected Features As….
  4. Set Format to GeoPackage.
  5. Beside File name, browse to 02_working/course.gpkg.
  6. Set Layer name to:
observations_in_management_area
  1. Set the output CRS to EPSG:2193.
  2. Confirm QGIS is saving only selected features. Because you used Save Selected Features As, this should already be the case.
  3. Leave Add saved file to map enabled.
  4. Click OK.
  5. Wait for the new layer to appear.
  6. Right-click observations_in_management_area.
  7. Open its attribute table.
  8. Confirm its row count matches the selection count from step 6.
  9. Close the table.
  10. Save the project.

8. Clear the old selection

  1. Choose Edit → Select → Deselect Features from All Layers, or use the Deselect Features from All Layers toolbar button if visible.
  2. Confirm the selection highlight disappears from the original observations layer.

This prevents an old selection from accidentally affecting a later operation.

9. Create a 100 metre buffer

  1. In Processing Toolbox search for:
Buffer
  1. Double-click the standard Buffer algorithm.
  2. Set Input layer to observations_in_management_area.
  3. Set Distance to:
100
  1. Because the input CRS is EPSG:2193, the distance is in metres.
  2. Leave segment/end-cap/join settings at their defaults for this teaching exercise.
  3. Leave Dissolve result off so each input point retains its own buffer feature.
  4. At the output destination, choose Save to GeoPackage….
  5. Select 02_working/course.gpkg.
  6. Set output layer name to:
observation_buffer_100m
  1. Click Run.
  2. Wait for completion.
  3. Click Close.
  4. Save the project.

You should now see

Circular buffer polygons around the selected teaching observations.

10. Check that 100 really means 100 metres

  1. Choose View → Toolbars → Attributes Toolbar if you cannot find a measurement tool.
  2. Choose Measure Line from the measurement tools.
  3. Click approximately at the centre point of one observation.
  4. Click at the outer edge of its buffer.
  5. Right-click to finish the measurement if required.
  6. The distance should be approximately 100 m.
  7. 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

  1. In Processing Toolbox search for:
Clip
  1. Double-click Clip.
  2. Set Input layer to observation_buffer_100m.
  3. Set Overlay layer to teaching_management_area.
  4. Set the output destination to Save to GeoPackage….
  5. Select 02_working/course.gpkg.
  6. Set the output layer name to:
buffer_clipped_to_management_area
  1. Click Run.
  2. Wait for completion.
  3. Click Close.
  4. 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

  1. In Processing Toolbox search for:
Intersection
  1. Double-click Intersection.
  2. Set Input layer to observation_buffer_100m.
  3. Set Overlay layer to teaching_management_area.
  4. Leave the input/overlay field lists at their defaults so attributes from both sources are available for comparison.
  5. Set output destination to Save to GeoPackage….
  6. Select 02_working/course.gpkg.
  7. Set layer name to:
buffer_management_intersection
  1. Click Run.
  2. Wait for completion.
  3. Click Close.
  4. Save the project.

13. Compare Clip and Intersection attributes

  1. Right-click buffer_clipped_to_management_area.
  2. Choose Open Attribute Table.
  3. Note which fields are present.
  4. Close it.
  5. Right-click buffer_management_intersection.
  6. Open its attribute table.
  7. Look for fields originating from teaching_management_area, such as area_id or purpose, as well as the original observation-related fields.
  8. 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

  1. Choose Processing → History… or open the Processing history/log through the Processing menu available in your installation.
  2. Find the recent entries for:
    • Select by location
    • Buffer
    • Clip
    • Intersection
  3. Click each entry and inspect its saved parameters or command information.
  4. Confirm the buffer distance was 100 and 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

  1. In the Browser panel find 02_working/course.gpkg.
  2. Expand it.
  3. Confirm these layers exist:
observations
observations_in_management_area
teaching_management_area
observation_buffer_100m
buffer_clipped_to_management_area
buffer_management_intersection
  1. 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

  1. Save the project.
  2. Close it.
  3. Reopen 03_project/qgis-course.qgz.
  4. Confirm the five derived/teaching analysis layers still load.
  5. Open observations_in_management_area and 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 observations layer 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