Learn R Programming

geostatsp (version 2.2.0)

geostatData: Prepare observations and covariates for a geostatistical model

Description

Extracts covariates at observation locations, aligns covariate rasters to a prediction grid, and returns the data structures used by glgm and lgm.

Usage

geostatData(formula, data, grid, covariates, buffer = 0)
# S3 method for SpatVector
geostatData(formula, data, grid, covariates, buffer = 0)
# S3 method for SpatRaster
geostatData(formula, data, grid = data, covariates = NULL, buffer = 0)
# S3 method for default
geostatData(formula, data, ...)

Value

A list with

data

For SpatVector input, a SpatVector with extracted covariates and a space cell identifier. For SpatRaster input, a data.frame of cell values.

grid

The (possibly buffered) square SpatRaster used as the model lattice.

covariates

A data.frame of covariate values on grid.

formula

Returned only by the SpatRaster method. Equal to the supplied formula, or a rewritten formula when log-offsets are aggregated.

Arguments

formula

Model formula. Names on the right-hand side are taken from data when present and otherwise extracted from covariates.

data

A SpatVector of point observations, or a SpatRaster of observations on a lattice.

grid

A SpatRaster giving the prediction grid (and the lattice for the spatial random effect). For the SpatRaster method this defaults to data.

covariates

A SpatRaster, a multi-layer SpatRaster, or a list of SpatRasters. Layer or list names must match names in formula.

buffer

Extra space padded around grid, passed to the same argument of squareRaster.

...

Ignored. The default method reports an error if data is not a SpatVector or SpatRaster.

See Also

glgm, lgm, squareRaster

Examples

Run this code
data("loaloa")
loaloa = unwrap(loaloa)
elevationLoa = unwrap(elevationLoa)
eviLoa = unwrap(eviLoa)

res = geostatData(
    y ~ elev + evi,
    data = loaloa,
    covariates = list(elev = elevationLoa, evi = eviLoa),
    grid = squareRaster(loaloa, cells = 20, buffer = 1e4)
)
names(res)
names(res$data)
res$grid

Run the code above in your browser using DataLab