buffr: Buffer function for rasters

Description Usage Arguments Details Value Author(s) Examples

Description

Buffr calculates a buffer around any user-defined cell value for RasterLayer objects.

Usage

1
2
3
buffr(r, distance, units = "geographic", target_value = 1,
  mask = TRUE, mask_value = NA, max_rows_at_once = 1e+08,
  verbose = TRUE)

Arguments

r

RasterLayer.

distance

numeric>0. The buffer distance. The units are defined in the units argument.

units

character. This argument must equal either "cell" or "geographic". If set to "cell", then the buffer distance is interpreted as the number of cells. If set to "geographic", then the distance is interpreted as being in the same units as the resolution of the raster file.

target_value

numeric. Cell value to perform the buffer operation on. Buffered cells will take on this value.

mask

logical. If TRUE then all cells that do not contain the target value are masked with the value defined in the mask_value argument (NA by default). If FALSE then all cells that do not contain the target value are returned with their original value.

mask_value

numeric. Value to use for masking when the mask argument is set to TRUE.

max_rows_at_once

numeric>0. Sets the maximum number of rows for R to process at once, which can cause larger jobs to be broken into smaller loops. Recommended to leave at the default value of 100000000.

verbose

logical. Should progress indicators be supressed?

Details

Buffr assigns a cell value based on whether the center of the cell falls within the buffer radius.

Buffr offers several advantages over the buffer function in the raster package v2.6-7:

  1. It is substantially faster, especially for large rasters and buffers. This is partially because the computationally intensive operations are implemented in C++ using the Rcpp package.

  2. The user can define which cell value to buffer.

  3. It includes progress indicators.

Value

RasterLayer

Author(s)

Ariel Fridman

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(raster)
r <- raster(ncol = 36, nrow = 18)
r[] <- NA
r[500] <- 1
buff <- buffr(r = r, distance = 20, units = "geographic", target_value = 1)
plot(buff)

r[100] <- 2
buff <- buffr(r = r, distance = 20, units = "geographic", target_value = 2, mask = FALSE)
plot(buff)

arielfri/buffr documentation built on March 28, 2021, 10:21 a.m.