Network gaps and stepping stones — Recipe (QGIS)

Tool-bound implementation of the Network gaps and stepping stones (Task) Task Schema in QGIS 4.2. Worked example: Habitat network at Ledreborg (Example).

Data you need

RoleFormLevel of measurementNotes
Patches with clusterpolygonsnominal cluster_idfrom Habitat network (Task)
Land where new habitat is possiblepolygons, or a raster to convertnominal land-use classese.g. farmland classes of a land-cover raster
Excluded land (optional)polygonsnominalroads, buildings: negative constraints
Strip width, minimum cluster sizenumbersratiofrom the Task’s choices

Each cluster’s own habitat (Task Schema steps 1–2)

  1. Dissolve (Tool - QGIS) on the patches, Dissolve field(s) cluster_id: each cluster’s habitat without the buffer, so gaps are measured between real patches.
  2. Extract by expression (Tool - QGIS) twice:
    • the main network: "cluster_id" = <id of the largest> (sort the attribute table by $area to find it)
    • the clusters to connect: "cluster_id" <> <id of the largest> AND $area >= <minimum m²>

Shortest connections (step 3)

Shortest line between features (Tool - QGIS): Source layer the clusters to connect, Destination layer the main network, Method Distance to Nearest Point on feature, Maximum number of neighbors 1.

Proposed new habitat (steps 4–6)

  1. Buffer (Tool - QGIS) on the lines: Distance = half the strip width, End cap style Flat, Dissolve result ticked.
  2. If the possible land is a raster: Reclassify by table with the possible classes → 1 (Use no data when no range matches), then Polygonize (raster to vector).
  3. Clip (Tool - QGIS): the strip, with the possible land as Overlay layer (positive constraint).
  4. Difference (Tool - QGIS): the result minus the habitat patches and any excluded land (negative constraints).
  5. Sum the lengths of the lines and the area of the new habitat with the statistics panel.

Checked in QGIS 4.2.2, October 2026.