Construct a lattice grid for inla.mesh

inla.mesh.lattice(x = seq(0, 1, length.out=2),
          y = seq(0, 1, length.out=2),
          z = NULL,
          dims = if (is.matrix(x)) {
                   dim(x)
                 } else {
                   c(length(x), length(y))
                 },
          units = NULL,
          crs = NULL)

Arguments

x

y

z

dims

units

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

crs

An optional CRS or inla.CRS object

Value

An inla.mesh.lattice object.

Author

Finn Lindgren finn.lindgren@gmail.com

See also

Examples

lattice = inla.mesh.lattice(seq(0, 1, length.out=17), seq(0, 1, length.out=10))

## Use the lattice "as-is", without refinement:
mesh = inla.mesh.create(lattice=lattice, boundary=lattice$segm)
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
mesh = inla.mesh.create(lattice=lattice, extend=FALSE)
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
plot(mesh)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found

## Refine the triangulation, with limits on triangle angles and edges:
mesh = inla.mesh.create(lattice=lattice,
                        refine=list(max.edge=0.08),
                        extend=FALSE)
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
plot(mesh)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found

## Add an extension around the lattice, but maintain the lattice edges:
mesh = inla.mesh.create(lattice=lattice,
                        refine=list(max.edge=0.08),
                        interior=lattice$segm)
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
plot(mesh)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found

## Only add extension:
mesh = inla.mesh.create(lattice=lattice, refine=list(max.edge=0.08))
#> Warning: error in running command
#> Error in fmesher.read(prefix, "manifold"): File '/tmp/Rtmp4ztB6d/fmesher53bd22475046.manifold' does not exist.
plot(mesh)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found