Skip to contents

Calculate a lattice projection to/from an inla.mesh

Usage

fm_evaluate(...)

# S3 method for inla.mesh
fm_evaluate(mesh, field, ...)

# S3 method for inla.mesh.1d
fm_evaluate(mesh, field, ...)

# S3 method for fm_evaluator
fm_evaluate(projector, field, ...)

fm_evaluator(...)

fm_evaluator_inla_mesh(mesh, loc = NULL, crs = NULL, ...)

fm_evaluator_inla_mesh_1d(mesh, loc, ...)

fm_evaluator_lattice(
  mesh,
  xlim = NULL,
  ylim = NULL,
  dims = c(100, 100),
  projection = NULL,
  crs = NULL,
  ...
)

# S3 method for inla.mesh
fm_evaluator(mesh, loc = NULL, lattice = NULL, crs = NULL, ...)

# S3 method for inla.mesh.1d
fm_evaluator(mesh, loc = NULL, xlim = mesh$interval, dims = 100, ...)

Arguments

...

Additional arguments passed on to methods.

mesh

An inla.mesh or inla.mesh.1d object.

field

Basis function weights, one per mesh basis function, describing the function to be evaluated at the projection locations

projector

An fm_evaluator object.

loc

Projection locations. Can be a matrix, SpatialPoints, SpatialPointsDataFrame, sf, sfc, or sfg object.

crs

An optional CRS or inla.CRS object associated with loc and/or lattice.

xlim

X-axis limits for a lattice. For R2 meshes, defaults to covering the domain.

ylim

Y-axis limits for a lattice. For R2 meshes, defaults to covering the domain.

dims

Lattice dimensions.

projection

One of c("default", "longlat", "longsinlat", "mollweide").

lattice

An inla.mesh.lattice() object.

Value

For fm_evaluate(mesh, ...), a list with projection information. For fm_evaluator(mesh, ...), an fm_evaluator object. For fm_evaluate(projector, field, ...), a field projected from the mesh onto the locations given by the projector object.

Functions

  • fm_evaluator(inla.mesh): The ... arguments are passed on to fm_evaluator_lattice() if no loc or lattice is provided.

See also

inla.mesh, inla.mesh.1d, inla.mesh.lattice

Author

Finn Lindgren finn.lindgren@gmail.com

Examples

if (bru_safe_inla()) {
  n <- 20
  loc <- matrix(runif(n * 2), n, 2)
  mesh <- INLA::inla.mesh.create(loc, refine = list(max.edge = 0.05))
  proj <- fm_evaluator(mesh)
  field <- cos(mesh$loc[, 1] * 2 * pi * 3) * sin(mesh$loc[, 2] * 2 * pi * 7)
  image(proj$x, proj$y, fm_evaluate(proj, field))
}

# \donttest{
if (bru_safe_inla() &&
  require(rgl)) {
  plot(mesh, rgl = TRUE, col = field, draw.edges = FALSE, draw.vertices = FALSE)
}
#> Loading required package: rgl
#> Warning: RGL: unable to open X11 display
#> Warning: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
# }