Habitat network — Recipe (QGIS)

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

Data you need

RoleFormLevel of measurementNotes
Habitat patchespolygonsnominal type (optional)e.g. from Nature content layer (Task)
Connection distancea numberratio (metres)from the species or species group in question
Patches with cluster (output)polygonsnominal cluster_id; ratio counts and areas

Build the clusters (Task Schema steps 3–5)

Buffer (Tool - QGIS) on the patches:

  • Distance: half the connection distance
  • Dissolve result: ticked
  • Keep disjoint results separate: ticked

This one dialog realises three Operators — dilation, dissolve and explode — and gives one feature per cluster. Then:

  1. Renumber feature ids (Tool - QGIS) on the clusters. Without it, saving to a GeoPackage fails (UNIQUE constraint failed), because the clusters share fid values.
  2. Field calculator (Tool - QGIS): an integer field cluster_id = $id.

Give each patch its cluster (step 6)

Join attributes by location (Tool - QGIS): Join to features in the patches, By comparing to the clusters, predicate intersect, field cluster_id, join type Take attributes of the first matching feature only (one-to-one).

Measure and classify (steps 7–8)

Field calculator (Tool - QGIS) on the joined patches:

  • n_in_cluster (integer) = count($id, group_by:="cluster_id")
  • cluster_area (decimal) = sum($area, group_by:="cluster_id")

Style the layer with Categorized on the expression

CASE WHEN "cluster_area" = maximum("cluster_area") THEN 'Main network'
     WHEN "n_in_cluster" = 1 THEN 'Isolated patch'
     ELSE 'Smaller cluster' END

Repeat with at least one other connection distance, as the Task’s choices recommend.

Checked in QGIS 4.2.2, October 2026.