modify: Modify gridded objects

Description Usage Arguments Details Value Examples

View source: R/modify.R

Description

Typical GIS operations modify gridded objects according to a given process. This can serve to identify certain objects or to prepare the quantitative assessment of the spatial object in question.

Usage

1
2
modify(input = NULL, by = NULL, sequential = FALSE, merge = FALSE,
  keepInput = FALSE)

Arguments

input

[RasterLayer(1) | list(.) thereof]
an object or a named list of objects, which should be modified. Typically retrieved via obtain, but can also be assembled "by hand".

by

[list(.)]
algorithm in which the operators to modify input are specified. Each operator is a list iteself and includes the operator name and its arguments as sub-elements; see Examples.

sequential

[logical(1)]
should the defined operators be carried out based on the output of the previous operator (TRUE), or separately based on the original input (FALSE, default); see Details.

merge

[logical(1)]
should the resulting object be merged to a raster stack (TRUE), or should it remain a list (FALSE, default).

keepInput

[logical(1)]
should input be retained (TRUE) or should it be discarded (FALSE, default)?

Details

Operators can be called several successive times with modified arguments. The following operators are recently defined...

... to select a subset of cells:

... to modify cell values:

... to determine objects:

... to morphologically modify a raster:

... to modify the overall raster:

Moreover, you can create your own operator or check this package's github page to suggest new algorithms or make a pull-request.

Value

A list of RasterLayers or a RasterStack of modified objects according to the number of chosen datasets and (combinations of) operators.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
input <- rtRasters$continuous

# employ modification with merely one operator
binarised <- rBinarise(input, thresh = 40)
visualise(binarised)

# employ several operators combined to an algorithm, 'obj' does not need to
# be specified per operator in the algorithm, as 'modify' assigns it.
getPatches <- list(list(operator = "rBinarise", thresh = 40),
                   list(operator = "rPatches"))
patches <- modify(input, by = getPatches, sequential = TRUE)
visualise(patches)

# To run separated sub-algorithms, use names for each operator to specify
# which elements should be computed sequentially.
getPatchNCats <- list(get_patches = list(operator = "rBinarise", thresh = 40),
                      get_patches = list(operator = "rPatches"),
                      get_categories = list(operator = "rCategorise", n = 5))
patchNCats <- modify(input, by = getPatchNCats, merge = TRUE)
visualise(patchNCats)

# Create objects that are usable later in the algorithm
getMedialAxis <- list(skeleton = list(operator = "rSkeletonise", background = 0),
                      medAxis = list(operator = "rPermute"),
                      medAxis = list(operator = "rDistance"),
                      medAxis = list(operator = "rMask", mask = "skeleton"))
MAT <- modify(binarised, by = getMedialAxis, merge = TRUE)
visualise(MAT, trace = TRUE)

EhrmannS/rasterTools documentation built on Sept. 4, 2019, 10:34 a.m.