
Last chance! 50% off unlimited learning
Sale ends in
This function returns a matrix (or matrices) for all focal values of a number of rows of a Raster* object
# S4 method for Raster
getValuesFocal(x, row, nrows, ngb, names=FALSE, padValue=NA, array=FALSE, ...)
Raster* object
Numeric. Row number, should be between 1 and nrow(x). Can be omitted to get all rows
Numeric. Number of rows, should be a positive integer smaller than row+nrow(x)
. Should be omitted if row
is omitted
Neighbourhood size. Either a single integer or a vector of two integers c(nrow, ncol)
logical. If TRUE
, the matrix returned has row and column names
numeric. The value of the cells of the "padded" rows and columns. That is 'virtual' values for cells within a neighbourhood, but outside the raster
logical. If TRUE
and x
has multiple layers, an array is returned in stead of a list of matrices
additional arguments (none implemented)
If x
has a single layer, a matrix with one row for each focal cell, and one column for each neighbourhood cell around it.
If x
has multiple layers, an array (if array=TRUE
) or a list of such matrices (one list element (matrix) for each layer)
# NOT RUN {
r <- raster(nr=5, nc=5, crs='+proj=utm +zone=12')
r[] <- 1:25
as.matrix(r)
getValuesFocal(r, row=1, nrows=2, ngb=3, names=TRUE)
getValuesFocal(stack(r,r), row=1, nrows=1, ngb=3, names=TRUE, array=TRUE)
# }
Run the code above in your browser using DataLab