rastergen: Generate random crop rasterstacks

Description Usage Arguments Value Note Examples

View source: R/rastergen.R

Description

Function to generate random crop raster sequences at plot or block level given an existing time series The output us used to run dynamic ecosystem service models (e.g. H<c3><a4>ussler et al. 2017) Requires lu.data. The function takes as input a matrix with rows for cells and columns for cell, plot, block, land-use, plot and block edge information The landuse info is for multiple years. The function generates crop frequencies for spatial units and samples from them. Allows to resample at different levels - e.g. plot or block. If random is FALSE than the observed pattern is simply replicated. ls is the spatial scale for sampling (plots or blocks)

Usage

1
rastergen(x, rid, random = TRUE, ls, lucols, nyout = 6, nlu = 13)

Arguments

x

takes as input a matrix with rows for cells and columns for cell, plot, block, land-use, plot and block edge information

rid

a raster with plot ids

random

If random is FALSE than the observed pattern is simply replicated.

exclude_field

A vector of identifier values to be considered as non-agricultural areas. Defaults to 0.

exclude_crop

A vector of crop codes to be considered as non-crop. Defaults to 14.

cell.size

A number indicating the cell height/widht in meters. Defaults to 25.

widthgreenedges

A number or vector of numbers indicating the assumed width of green field edges in metres. Defaults to 2.

model

One of two final lmer models used in Sirami et al. (model3 or model5). Defaults to model3.

core

logical (TRUE/FALSE), indicates whether the core of the raster should be used in the computation.

corewidth

minimum distance from the centre point to the edge of the core, in units of the projection (usually metres).

Value

A list containing the estimates, the model call, and a data frame of the explanatory variables

Note

if permanent grassland in the plot, then it is grassland in the complete time series. Same for permanent plot and non-agr areas. If we manage at the block-level then the permanent grassland disappears

Examples

1
2
3
4
5
6
7
load("landuse.data.RData") # list for each landscape (lu.data) with the landuse per year (lu15 to lu 10) per cell (column)
load("plot.raster.RData") # raster with plot codes (rplots)
load("lu.codes.RData") #
rblocks22<-raster("rblocks22.tif") # blocks - can also be retrieved from lu.data if necessary
outrandomplot<-rastergen(x=lu.data[["ls 22"]], rid=rplots[["ls 22"]], random=TRUE, ls="plots", lucols=4:9)
outobserved<-rastergen(x=lu.data[["ls 22"]], rid=rplots[["ls 22"]], random=FALSE, ls="plots", lucols=4:9)
outrandomblock<-rastergen(x=lu.data[["ls 22"]], rid=rblocks22, random=TRUE, ls="blocks", lucols=4:9)

yclough/ecodeal documentation built on May 14, 2019, 2:01 a.m.