Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

focalValues

Get focal values


Description

Get a matrix in which each row had the focal values of a cell. These are the values of a cell and a rectangular window around it.

Usage

## S4 method for signature 'SpatRaster'
focalValues(x, w=3, row=1, nrows=nrow(x), fill=NA)

Arguments

x

SpatRaster or SpatVector

w

window. The window can be defined as one (for a square) or two odd numbers (row, col); or with an odd sized matrix

row

positive integer. Row number to start from, should be between 1 and nrow(x)

nrows

positive integer. How many rows?

fill

numeric used as values for imaginary cells outside the raster

Value

matrix

Examples

r <- rast(ncol=4, nrow=4, crs="+proj=utm +zone=1 +datum=WGS84")
values(r) <- 1:ncell(r)
focalValues(r)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.