BumpDisconnectCells: Adjust Vertically Disconnected Cells

View source: R/BumpDisconnectCells.R

BumpDisconnectCellsR Documentation

Adjust Vertically Disconnected Cells

Description

Given upper and lower surfaces (raster layers) of a three-dimensional (3D) model layer, this function incrementally decreases lower cell values until a minimum vertical overlap between adjacent model cells is satisfied.

Usage

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

Arguments

rs

'Raster*'. Collection of two raster layers, the first and second layers represent the upper and lower surface of a 3D model layer.

min.overlap

'numeric' number. Minimum vertical overlap between horizontally adjacent model cells.

bump.by

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

max.itr

'integer' count. Maximum number of iterations.

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.

Value

An object of class 'RasterLayer' that can be added to rs[[2]] to ensure connectivity between model layer cells. Cell values in the returned raster grid represent vertical adjustments.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

Examples

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)
rs <- raster::stack(r_top, r_bot)
r <- BumpDisconnectCells(rs, min.overlap = 0.1)
raster::plot(r, col = GetColors(255, reverse = TRUE))
summary(r[])

r_bot_new <- r_bot + r


USGS-R/inlmisc documentation built on Sept. 17, 2022, 2:38 a.m.