getValuesFocal | R Documentation |
This function returns a matrix (or matrices) for all focal values of a number of rows of a Raster* object
## S4 method for signature 'Raster'
getValuesFocal(x, row, nrows, ngb, names=FALSE, padValue=NA, array=FALSE, ...)
x |
Raster* object |
row |
Numeric. Row number, should be between 1 and nrow(x). Can be omitted to get all rows |
nrows |
Numeric. Number of rows, should be a positive integer smaller than |
ngb |
Neighbourhood size. Either a single integer or a vector of two integers |
names |
logical. If |
padValue |
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 |
array |
logical. If |
... |
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)
getValues, focal
r <- raster(nr=5, nc=5, crs='+proj=utm +zone=12')
values(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.