nhapply: Main Neighbour Apply Function

Description Usage Arguments

View source: R/nhapply_master.R

Description

Apply functions on neighbourhood of pixels

Usage

1
2
3
nhapply(mat, FUN, restriction = "TRUE", weights = 1, density = FALSE,
  neighb_type = 1, width = 1, include.own = FALSE, custom_neighb,
  FUN_advanced, transition = TRUE, force = FALSE)

Arguments

mat

is an input matrix to apply a function on

FUN

is a function, that is applied on the neighbourhood of each point of a matrix. Optimised functions are: "mean", "sum", "max", "min", "maxCount", "maxCountValue" (which value occurs most often). It is possible to add a customised function like function(x) ... which must return a single value.

restriction

restricts the input matrix according to some condition as string. For example nhapply(mat, sum, restriction = "mat > 9").

weights

is a vector of weights that is used when summing up a neighbourhood. Vector length must be the same as points in neighbourhood.

density

if True, weights vector is scale to 0 - 1

neighb_type

specifies the type of surrounding: Type 1 is square-shaped ("Moore-Neighbourhood") Type 2 is cross-shaped ("Von-Neumann-Neighbourhood") Type 3 is diamond-shape

width

specifies how many neighbour pixels horizontally and vertically from center pixel should be included

include.own

tells, if the value of the center pixel should be included

custom_neighb

can be a matrix with 2 columns describing the x- and y-coordinates of the pixels to use or it can be a square matrix with odd number of rows and columns describing the neighbourhood and weights of each neighbour-pixel (0 means not using!)

FUN_advanced

can be used for more custom use-cases. The advanced function is applied on an open matrix where each column represents a point in a matrix and the rows its neighbourhood. Output should be a vector of same length as the number of pixels in the input matrix.

transition

if FALSE, matrix end at the sides, if TRUE, neighbourhood includes pixel from other side.

force

if your custom function outputs a different number of values than the number of points of the input matrix, force will force the program to apply the function. Do not use it, seriously, don't!


Tobiaspk/RPackage_nhapply documentation built on Feb. 19, 2021, 12:13 a.m.