erodil_raster: Raster erosion and dilation

Description Usage Arguments Value Author(s) Examples

Description

This function apply morphology() to raster objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
erodil_raster(raster, ...)

## S4 method for signature 'RasterLayer'
erodil_raster(
  raster,
  erosion = TRUE,
  dilation = TRUE,
  erosion_first = TRUE,
  nt = 1,
  ...
)

Arguments

raster

An object of class RasterLayer containing NA values. Note that as in the function morphology(), erosion and dilation is applied to non-NA values.

...

Further arguments passed to raster().

erosion

A logical value indicating whether the data will be eroded or not.

dilation

A logical value indicating whether the data will be dilated or not.

erosion_first

A logical value indicating whether erosion should be carried out before dilation or vice versa.

nt

Number of times to be processed (passed to morphology()).

Value

A RasterLayer object with value 1 for the processed features and NA for the background.

Author(s)

Jan Blöthe and Miguel Alvarez (kamapu78@gmail.com).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Load installed rasterLayer
require(raster)
r <- raster(file.path(path.package("spatialist"), "binras.tif"))

## Make only erosion or only dilation
plot(stack(list(original=r,
         eroded=erodil_raster(r, dilation=FALSE),
			dilated=erodil_raster(r, erosion=FALSE))))

## By default erosion will be done before dilation
plot(stack(list(original=r,
			eroded_first=erodil_raster(r),
			dilated_first=erodil_raster(r, erosion_first=FALSE),
			both=erodil_raster(erodil_raster(r, erosion_first=FALSE)))))

kamapu/spatialist documentation built on April 13, 2021, 5:18 a.m.