Learn R Programming

inlabru (version 2.3.1)

is.inside: Query if a point is inside the mesh boundary

Description

Query if a point is inside the mesh boundary

Usage

is.inside(mesh, loc, mesh.coords = NULL)

Arguments

mesh

an inla.mesh object.

loc

Points in space stored either as data.frame, a two-column matrix of x and y coordinates or a SpatialPoints object.

mesh.coords

Coordinate names of the mesh. Use only if loc is a data.frame with respective column names.

Value

Single column matrix of Boolean values indicating if a point is inside the mesh.

Examples

Run this code
# NOT RUN {
if (require("INLA", quietly = TRUE)) {
  # Load Gorilla data

  data("gorillas", package = "inlabru")

  # Check if all Gorilla nests are inside the mesh

  all(is.inside(gorillas$mesh, gorillas$nests))

  # Also works for locations not stored as SpatialPoints object

  loc <- coordinates(gorillas$nests)
  all(is.inside(gorillas$mesh, loc))
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab