Description Usage Arguments Details Value Examples
View source: R/LandCoverSpread.R
This function runs a simulation of landcover spread, using bootstrapped results. It returns a list of landcover rasters and a list of the rasters for your dependent variable; one for each year.
1 2 3 4 5 6 7 8 9 10 11 12 13 | LandCoverSpread(
infest_val,
suscep_val,
spread_rate,
birdcell = 0,
simlength,
simulation_count,
lc_raster,
dep_var_raster_initial,
dep_var_raster_pred,
dep_var_modifier = NA,
silent = FALSE
)
|
infest_val |
numerical. Value of the landcover that will be spreading. |
suscep_val |
numerical. Vector of landcover values that are susceptible to the spread. |
spread_rate |
numerical. Value between 0 and 1 indicating the annual spread rate of the invading landcover. |
birdcell |
numerical. Value between 0 and 1 indicating the probability a random cell can be invaded, regardless of adjacency to existing invaded pixels. |
simlength |
integer. Number of years the simulation should run. |
simulation_count |
integer. Length of simulation bootstrap. |
lc_raster |
raster. The initial landcover raster. |
dep_var_raster_initial |
raster. The initial raster for the dependent variable. It is recommended you use a raster of predicted values rather than raw data (i.e. use |
dep_var_raster_pred |
raster. A raster with predicted values for the dependent variable in all pixels susceptible to invasion. Usually a raster from |
dep_var_modifier |
numerical. A scalar to optionally return a list of rasters with modified dep_var rasters (e.g. multiply water yield rasters to obtain recharge rasters) |
silent |
logical. Suppress printing notification when each simulation is done. Default is |
The output is a list of rasters: landcover over time, dep var over time, modified dep var over time (if specified), change in dep var over time, change in modified dep var over time (if specified), cumulative change in dep var, cumulative change in modified dep var (if specified)
Lists of rasters (landcover and dependent variable) and, optionally, raster files to a directory of your choosing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # load packages
library(LandCover); library(foreach); library(raster)
# initialize data.frame with coordinates
dat <- expand.grid(x = 1:20, y = 1:20, KEEP.OUT.ATTRS = FALSE)
# create some data: elevation, landcover, and temp/ET dependent on elevation and landcover
dat$elevation <- with(dat, 50 + 2*x + 5*y + rnorm(nrow(dat), sd = 7))
dat$landcover <- ifelse(dat$elevation < median(dat$elevation), 1, 2)
dat$temp <- with(dat, (120-0.7*(0.5*elevation + 0.3*y - 0.5*x + ifelse(landcover == 'lc1', -30, 0) + rnorm(nrow(dat)))))
dat$ET <- with(dat, ( -0.4*(-2*temp + 0.5*y - 1.0*x + ifelse(landcover == 'lc1', +20, 0) + rnorm(nrow(dat)))))
# run the gls model
regression_results <- gls_spatial(data = dat, landcover_varname = 'landcover', landcover_vec = c(1,2),
reg_formula = ET ~ elevation + temp, error_formula = ~ x + y)
# predict values of ET before and after invasion
pred_values <- gls_spatial_predict(data = dat, regression_results = regression_results, landcover_varname = 'landcover', landcover_invasive = 1, landcover_susceptible = 2,
dep_varname = 'ET', x_coords_varname = 'x', y_coords_varname = 'y')
# get landcover raster
lc_raster <- rasterFromXYZ(dat[c('x', 'y', 'landcover')])
# run landcover simulation
landcover_sim <- LandCoverSpread(infest_val = 1, suscep_val = 2, spread_rate = 0.05, birdcell = 0, simlength = 15, simulation_count = 100,
lc_raster = lc_raster, dep_var_raster_initial = pred_values$`Predicted values raster, current landcover`,
dep_var_raster_pred = pred_values$`Predicted values raster, post-invasion`,
dep_var_modifier = 0.80, silent = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.