build_mesh | R Documentation |
build_mesh function takes a sf object and mesh arguments to build an appropriate mesh for the spatial field.
build_mesh(shapes, mesh_args = NULL, mesh.args = NULL)
shapes |
sf covering the region under investigation. |
mesh_args |
list of parameters that control the mesh structure. convex, concave and resolution, to control the boundary of the inner mesh, and max.edge, cutoff and offset, to control the mesh itself, with the parameters having the same meaning as in the INLA functions inla.convex.hull and inla.mesh.2d. cut has been deprecated - use cutoff instead. |
mesh.args |
Deprecated. |
The mesh is created by finding a tight boundary around the polygon data, and creating a fine mesh within the boundary and a coarser mesh outside. This speeds up computation time by only having a very fine mesh within the area of interest and having a small region outside with a coarser mesh to avoid edge effects.
Six mesh parameters can be specified as arguments: convex, concave and resolution, to control the boundary of the inner mesh, and max.edge, cutoff and offset, to control the mesh itself, with the names meaning the same as used by the fmesher functions fm_nonconvex_hull_inla and fm_mesh_2d.
Defaults are: pars <- list(convex = -0.01, concave = -0.5, resolution = 300, max.edge = c(3.0, 8), cutoff = 0.4, offset = c(1, 15)).
An inla.mesh object
## Not run:
polygons <- list()
for(i in 1:14) {
row <- ceiling(i/10)
col <- ifelse(i %% 10 != 0, i %% 10, 10)
xmin = 2*(col - 1); xmax = 2*col; ymin = 2*(row - 1); ymax = 2*row
polygons[[i]] <- list(cbind(c(xmin, xmax, xmax, xmin, xmin),
c(ymax, ymax, ymin, ymin, ymax)))
}
polys <- lapply(polygons, sf::st_polygon)
response_df <- data.frame(area_id = 1:100,
response = runif(100, min = 0, max = 10))
spdf <- sf::st_sf(polys, response_df)
my_mesh <- build_mesh(spdf)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.