Learn R Programming

raster (version 2.0-05)

getValuesFocal: Get focal raster cell values

Description

This function returns all values or a row of values for a Raster* object. It will take them from memory if available, else it will read them from disk. Function values is a shorthand version of getValues.

Usage

## S3 method for class 'Raster':
getValuesFocal(x, row, nrows, ngb, ...)

Arguments

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 an integer > 0 & < row+nrow(x). Should be omitted if row is omitted
ngb
Neighborhood size. Either a single integer or a vector of two integers c(nrow, ncol)
...
Additional arguments. One implemented: names (Boolean). If TRUE, the matrix returned has row and column names

Value

  • If x has a single layer, a matrix with one row for each focal cell, and one column for each neighborhood cell around it. If x has multiple layers, a list of such matrices (one list element / matrix for each layer)

See Also

getValues, focal

Examples

Run this code
r <- raster(nr=5, nc=5, crs='+proj=utm +zone=12')
r[] <- 1:25
as.matrix(r)
getValuesFocal(r, row=1, nrows=3, ngb=3, names=TRUE)

Run the code above in your browser using DataLab