Learn R Programming

spatstat.linnet (version 3.4-0)

linim.apply: Apply Function Pixelwise to List of Images on a Network

Description

Returns a pixel image obtained by applying a given function to corresponding pixels in a list of several pixel images on a linear network.

Usage

linim.apply(X, FUN, ..., fun.handles.na=FALSE, check=TRUE, verbose=TRUE)

Value

A pixel image on a network (object of class "linim") or a list of pixel images on the same network.

Arguments

X

A list of pixel images on the same network (objects of class "linim").

FUN

A function that can be applied to vectors, or a character string giving the name of such a function.

...

Additional arguments to FUN.

fun.handles.na

Logical value specifying what to do when the data include NA values. See Details.

check

Logical value specifying whether to check that the images in X are compatible (for example that they have the same grid of pixel locations) and to convert them to compatible images if necessary.

verbose

Logical value specifying whether to print informative messages.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.

Details

The argument X should be a list of pixel images on a network (objects of class "linim"). They should all be defined on the same network. If the images do not have identical pixel grids, they will be converted to a common grid using harmonise.linim.

At each pixel location, the values of the images in X at that pixel will be extracted as a vector; the function FUN will be applied to this vector; and the return value of FUN will become the pixel value of the resulting image. For example linim.apply(X, mean) will return a pixel image in which the value of each pixel is the average of the corresponding pixel values in the images in X.

If the result of FUN is a vector, then the result of linim.apply will be a list of images. For example linim.apply(X, range) will return a list of two images containing the pixelwise minimum and pixelwise maximum, respectively, of the input images in X.

The argument fun.handles.na specifies what to do when some of the pixel values are NA.

  • If fun.handles.na=FALSE (the default), the function FUN is never applied to data that include NA values; the result is defined to be NA whenever the data contain NA.

  • If fun.handles.na=TRUE, the function FUN will be applied to all pixel data, including those which contain NA values.

See Also

eval.linim for algebraic operations with images.

Examples

Run this code
  # list of two pixel images
  X <- runiflpp(5, simplenet, nsim=2)
  Y <- solapply(lapply(X, distfun), as.linim)
  plot(Y)
  linim.apply(Y, max)
  linim.apply(Y, sum)
  linim.apply(Y, range)

Run the code above in your browser using DataLab