rErode: Morphologically erode foreground patches in a raster

Description Usage Arguments Details Value See Also Examples

View source: R/modify.operators.R

Description

The morphological operation 'erode' removes cells at the boundary of a foreground patch in a binarised raster.

Usage

1
rErode(obj, kernel = NULL)

Arguments

obj

[RasterLayer(1)]
The object to modify.

kernel

[matrix(1)]
scan the raster with this kernel (default is a 3 by 3 cells diamond kernel).

Details

A morphological dilation changes the values in a raster after comparing each value to a kernel that moves systematically across the raster. A kernel is any 2D array with an odd number of cells in each dimension and a focal cell in the middle. The cells of a kernel can have four categories of values: 0, 1, NA and any value > 1. When the kernel values match the values of the input raster, the input raster cell covered by the focal kernel cell is modified according to a specific operation, for instance the smallest value covered by the kernel is assigned.

Rasters are either binary or non-binary (greyscale) rasters.

Value

A RasterLayer of the same dimension as obj, where an erosion has been performed.

See Also

Other operators to morphologically modify a raster: rDilate, rMorph

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# use as standalone
input <- rtData$continuous
binarised <- rBinarise(input, thresh = 30)
visualise(rErode(obj = binarised))

# use another kernel
(myKernel <- matrix(1, 3, 3))
visualise(rErode(binarised, kernel = myKernel), new = TRUE)

# dilate also non-binary rasters
visualise(raster::stack(input, rErode(obj = input)))

EhrmannS/rasterTools documentation built on Feb. 4, 2019, 11:22 a.m.