pixFilter: pixFilter

Description Usage Arguments Details Value Examples

View source: R/pixFilter.R

Description

Erosion and dilation filter of a raster image.

Usage

1
pixFilter(x, y, method)

Arguments

x

Object of class RasterLayer.

y

A numeric element.

method

A character element. One of "erode" or "dilate".

Details

Uses focal to filter x using either an erosion or a dilation filter, specified by method. If "erosion" is chosen, the function will identify and filter out border pixels around each cluster of pixels in x. Small or isolated groups of pixels will also be removed. If "dilation" is set, the function will increase the size of each cluster of pixels and simultaneously remove all gaps within them. The size of the buffer used in this function is defined by y and is expressed in number of pixels.

Value

A RasterLayer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{

require(raster)

# read raster data
r <- raster(system.file("extdata", "ndvi.tif", package="fieldRS")) > 2000
r[r == 0] <- NA

# filter image (3x3 erosion)
or <- pixFilter(r, 1, "erode")
plot(r)
plot(or)

#' # filter image (3x3 dilation)
or <- pixFilter(r, 1, "dilate")
plot(r)
plot(or)

}

RRemelgado/fieldRS documentation built on June 5, 2020, 1:48 p.m.