Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (55 sloc) 2.35 KB
title: "establishment"
author: ''
date: "7 December 2016"
html_document: default
pdf_document: default
# Overview
This is a very simple 'spread and establish' module. It has a contagious component, it evaluates conditions in a set of "starting" locations on a raster and a set of "potential arriving locations". This could emulate dispersal of many types of species, where the abundance of a set of locations determines how many "things" (e.g., seeds or insects) leave, and the "quality" of a set of locations which determines how many "things" land and establish.
**This is currently used in teaching.**
# Usage
```{r module_usage, eval=TRUE, echo=TRUE, message=FALSE, warning=FALSE}
modulePath <- file.path(dirname(tempdir()), "modules")
downloadModule("establishment", path = modulePath)
modules <- list("establishment")
mySim <- simInit(modules = modules)
# make sure the plotting device is clear
## Plotting
The main plot is simply a map of where establishment will occur.
# Experiment
What happens when we vary the number of source locations and the threshold for establishment?
```{r experiment, eval=TRUE, echo=FALSE, message=FALSE, warning=FALSE}
# factorial experiment
expList <- list(establishThresh=as.list(1:9/10),
Nsource = as.list(1:10*2))
# Run the experiment
if(interactive()) dev()
out <- experiment(mySim, params = list(establishment = expList),
.plotInitialTime=NA) # turn off plotting
# plot the experiment -- how many establish by parameter combo
expDF <- cbind(expand.grid(expList),
(sapply(out, function(sim) sum(sim$establish[]))))
expDF <- data.frame(sapply(expDF, unlist, recursive = FALSE))
g <- ggplot(expDF, aes(establishThresh, Nsource)) +
geom_raster(aes(fill=numEstablishments)) +
low="lightgreen", trans = "log",
breaks=c(1,10,100,500, 1000))
# Data dependencies
## Input data
None required. This is a teaching module that creates its own inputs.
## Output data
A binary raster layer indicating places that were both "close" to a source, and of high enough quality to pass the establishment threshold parameter.