Skip to contents

Generate terra, sf, or sp lattice locations

Usage

fm_pixels(mesh, nx = 150, ny = 150, mask = TRUE, format = "sf")

Arguments

mesh

An inla.mesh object

nx

Number of pixels in x direction

ny

Number of pixels in y direction

mask

If logical and TRUE, remove pixels that are outside the mesh. If mask is an sf or Spatial object, only return pixels covered by this object.

format

character; "sf", "terra" or "sp"

Value

sf, SpatRaster, or SpatialPixelsDataFrame covering the mesh

Author

Fabian E. Bachl bachlfab@gmail.com and Finn Lindgren finn.lindgren@gmail.com

Examples

# \donttest{
if (require(ggplot2, quietly = TRUE)) {
  data("mrsea", package = "inlabru")
  pxl <- fm_pixels(mrsea$mesh,
    nx = 50, ny = 50, mask = mrsea$boundary,
    format = "terra"
  )
  ggplot() +
    gg(pxl, fill = "grey", alpha = 0.5) +
    gg(mrsea$mesh)
}
#> Warning: [setValues] values is larger than the size of cells

# }