Learn R Programming

inlmisc (version 0.3.2)

BumpDisconnectCells: Adjustment for Vertically Disconnected Cells

Description

This function decreases model cell values (such as land-surface elevations) in the lower raster layer if they violate a minimum vertical overlap between adjacent cells.

Usage

BumpDisconnectCells(rs, min.overlap = 2, bump.by = 0.1, max.itr = 10000)

Arguments

rs

'RasterStack'. A collection of two raster layers, the first and second layers represent the top and bottom of a model layer.

min.overlap

'numeric'. Minimum vertical overlap between adjacent cells.

bump.by

'numeric'. Amount to decrease a cell value by during each iteration of the algorithm.

max.itr

'numeric'. Maximum number of iterations.

Value

Returns a 'RasterLayer' that can be added to rs[[2]] to ensure connectivity between cells. Cell values in the returned raster grid represent vertical adjustments.

Details

During each iteration of the algorithm: (1) Cells are identified that violate the minimum vertical overlap between adjacent cells; that is, the bottom of cell i is greater than or equal to the top of an adjacent cell j minus the minimum overlap specified by the min.overlap argument. (2) For cells violating the minimum vertical overlap, lower raster layer (rs[[2]]) values are decreased by the value specified in the bump.by argument.

Examples

Run this code
# NOT RUN {
set.seed(0)
r.top <- raster::raster(ncols = 10, nrows = 10)
r.bot <- raster::raster(ncols = 10, nrows = 10)
r.top[] <- rnorm(raster::ncell(r.top), mean = 12)
r.bot[] <- rnorm(raster::ncell(r.bot), mean = 10)
summary(r.top - r.bot)

r <- BumpDisconnectCells(raster::stack(r.top, r.bot), min.overlap = 0.1)
raster::plot(r.bot + r)

# }

Run the code above in your browser using DataLab