sample.lgcp | R Documentation |
This function provides point samples from one- and two-dimensional
inhomogeneous Poisson processes. The log intensity has to be provided via its
values at the nodes of an fm_mesh_1d
or fm_mesh_2d
object. In between
mesh nodes the log intensity is assumed to be linear.
sample.lgcp(
mesh,
loglambda,
strategy = NULL,
R = NULL,
samplers = NULL,
ignore.CRS = FALSE
)
mesh |
An fmesher::fm_mesh_1d or fmesher::fm_mesh_2d object |
loglambda |
vector or matrix; A vector of log intensities at the mesh
vertices (for higher order basis functions, e.g. for |
strategy |
Only relevant for 2D meshes. One of |
R |
Numerical value only applicable to spherical and geographical
meshes. It is interpreted as |
samplers |
A |
ignore.CRS |
logical; if |
For 2D processes on a sphere the R
parameter can be used to adjust to
sphere's radius implied by the mesh. If the intensity is very high the
standard strategy
"spherical" can cause memory issues. Using the
"sliced-spherical" strategy can help in this case.
For crs-less meshes on R2: Lambda is interpreted in the raw coordinate system. Output has an NA CRS.
For crs-less meshes on S2: Lambda with raw units, after scaling the mesh
to radius R
, if specified.
Output is given on the same domain as the mesh, with an NA CRS.
For crs meshes on R2: Lambda is interpreted as per km^2, after scaling the
globe to the Earth radius 6371 km, or R
, if specified. Output given in
the same CRS as the mesh.
For crs meshes on S2: Lambda is interpreted as per km^2, after scaling the
globe to the Earth radius 6371 km, or R
, if specified. Output given in
the same CRS as the mesh.
A data.frame
(1D case),
SpatialPoints (2D flat and 3D spherical surface cases)
SpatialPointsDataFrame (2D/3D surface cases with multiple samples).
For multiple samples, the data.frame
output has a
column 'sample'
giving the index for each sample.
object of point locations.
Daniel Simpson dp.simpson@gmail.com (base rectangle and spherical algorithms), Fabian E. Bachl bachlfab@gmail.com (inclusion in inlabru, sliced spherical sampling), Finn Lindgren finn.lindgren@gmail.com (extended CRS support, triangulated sampling)
# The INLA package is required
if (bru_safe_inla() &&
bru_safe_sp() &&
require("sp")) {
vertices <- seq(0, 3, by = 0.1)
mesh <- fm_mesh_1d(vertices)
loglambda <- 5 - 0.5 * vertices
pts <- sample.lgcp(mesh, loglambda)
pts$y <- 0
plot(vertices, exp(loglambda), type = "l", ylim = c(0, 150))
points(pts, pch = "|")
}
# The INLA package is required
if (bru_safe_inla() &&
require(ggplot2, quietly = TRUE) &&
bru_safe_sp() &&
require("sp") &&
require("terra", quietly = TRUE) &&
require("sf", quietly = TRUE)) {
gorillas <- gorillas_sp()
pts <- sample.lgcp(gorillas$mesh,
loglambda = 1.5,
samplers = gorillas$boundary
)
ggplot() +
gg(gorillas$mesh) +
gg(pts)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.