Landscape connectivity in R

Patch metrics, least-cost paths, circuit theory and landscape genetics in R: building a between-site distance and then testing what it actually predicts.

A connectivity analysis starts with a map that says habitat here, hostile ground there, and it ends with a distance for every pair of places: distance as the organism experiences it rather than as the map draws it. Everything in between is modelling. Cells get a movement cost, the costs get combined into a between-place distance, and that distance is then asked to predict something real, such as whether a population persists, where animals actually cross a road, or how much genetic differentiation has accumulated between two sites.

The honest starting position is that every distance of this kind is a caricature of movement. A straight line ignores the ground completely. A least-cost path assumes the animal knows the whole surface in advance and takes the bargain route. Effective resistance assumes it wanders without memory. Real dispersal is none of those, so the question is never which model is true, only which caricature is close enough to be useful for the decision in front of you. These tutorials build each distance by hand in base R and then score it against an outcome, because a connectivity metric that has never been tested against anything observable is a picture rather than a measurement.

Pattern and movement cost

Before any movement model comes the map itself: how much habitat there is, how it is arranged, and whether it hangs together at all. Then the cost surface arrives, and with it a set of decisions that no data has yet constrained.

  • Patch metrics and fragmentation in R labels patches from a raster by hand, so the definition of a patch stops being a package default, and shows how abruptly a habitat map stops being joined up as cover falls past its threshold.
  • Least-cost paths and resistance surfaces prices the crossing of every cell and finds the cheapest route by sweeping the cost field until it settles. This is the standard tool of the field, and also the one most often pushed past what it can support.
  • Circuit theory and effective resistance swaps the single cheapest route for current spread over all routes at once, then constructs the case where the two metrics disagree about which corridor is worth protecting: redundancy is invisible to a path.
  • Checking a connectivity analysis treats the resistance values as an assumption rather than an input. Calibrate them against a process you can see, ask what the metric predicts, change the cost transform, and coarsen the cell size to find out whether the ranking survives any of it.

Connectivity and gene flow

Gene flow leaves a record, which makes genetic data the closest thing to an external test that connectivity modelling has. Differentiation between sites is an outcome, so competing cost models can be scored against it instead of argued about. The price is a set of problems that belong to the genetic side.

  • Isolation by distance and by resistance regresses a linearised measure of differentiation on rival between-site distances, which puts straight-line separation and modelled movement cost in direct competition on the same axis.
  • Multiple matrix regression with MMRR fits several distance matrices together and takes its significance from permuting rows and columns as a unit, because pairs that share a site are not separate observations and ordinary standard errors act as though they were.
  • Optimising a resistance surface stops guessing the cost values and searches for them instead, then builds the null distribution a tuned fit needs before its improvement in fit can be read as evidence about movement.
  • Checking a landscape genetics analysis works through the failures that survive a convincing fit: non-independent pairs, a barrier sitting exactly where distance already is, the generations of lag between fragmentation and its genetic signal, and how many markers the precision you are claiming would actually require.

What these tutorials assume

Base R and a single plotting package, nothing else, with rasters held as plain matrices and the algorithms written out rather than called from a connectivity package. The landscapes are simulated, so the true movement rule is known while the analysis runs, which is the only setting in which a metric can be caught being wrong. Costs are relative throughout: what matters is the ratio between habitat and matrix, never the units the resistance values are quoted in.

Where this connects

Connectivity work sits between two other clusters on this site, and reads better with a foot in each. The pattern side belongs to landscape ecology, while the outcome side is population genetics with a map attached.

  • Population genetics in R supplies the allele-frequency machinery the genetic distances rest on: what an F-statistic measures, what its ceiling depends on, and how much a differentiation estimate licenses you to say.
  • Metapopulation capacity moves up from pairs of sites to whole landscapes, ranking them by whether a species can persist across the network at all.
  • Fitting dispersal kernels works on the movement data itself, which is where the dispersal assumptions buried in a cost model can be replaced by estimates.
  • Spatial autocorrelation and Moran’s I covers the statistical dependence that arrives with any spatial data, including the version of it that inflates significance in pairwise distance analyses.

Newsletter

Get new tutorials by email

New R and QGIS tutorials for ecologists, straight to your inbox. No spam; unsubscribe anytime.

By subscribing you agree to receive these emails and confirm your address once. See the privacy policy.