## Load raster landscape
tiny <- terra::rast(
system.file("extdata", "tiny.asc", package = "grainscape", mustWork = TRUE)
)
## Create a resistance surface from a raster using an is-becomes reclassification
tinyCost <- terra::classify(tiny, rcl = cbind(c(1, 2, 3, 4), c(1, 5, 10, 12)))
## Produce a patch-based MPG where patches are resistance features=1
tinyPatchMPG <- MPG(cost = tinyCost, patch = tinyCost == 1)
## Extract a representative subset of 5 grains of connectivity
tinyPatchGOC <- GOC(tinyPatchMPG, nThresh = 5)
## Very quick visualization at the finest scale/grain/threshold
tinyPatchGOCgrain <- grain(tinyPatchGOC, whichThresh = 1)
if (interactive()) {
plot(tinyPatchGOCgrain, col = topo.colors(10))
}
## Visualize the model at the finest scale/grain/threshold
## Manual control of plotting
if (interactive()) {
plot(
grain(tinyPatchGOC, whichThresh = 1)@voronoi,
col = sample(rainbow(100)),
legend = FALSE,
main = "Threshold 1"
)
}
Run the code above in your browser using DataLab