inla.over_sp_mesh.RdWrapper for the over method to find triangle centroids
or vertices inside sp polygon objects
inla.over_sp_mesh(x, y, type = c("centroid", "vertex"), ignore.CRS = FALSE)geometry (typically a SpatialPolygons object) for the queries
an inla.mesh object
the query type; either 'centroid' (default, for triangle centroids),
or 'vertex' (for mesh vertices)
logical; whether to ignore the coordinate system information in x and y
(default FALSE)
A vector of triangle indices (when type is 'centroid') or
vertex indices (when type is 'vertex')
# Create a polygon and a mesh
obj <- sp::SpatialPolygons(list(Polygons(list(Polygon(rbind(c(0,0),
c(50,0),
c(50,50),
c(0,50)))),
ID=1)),
proj4string = inla.CRS("longlat_globe"))
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
mesh <- inla.mesh.create(globe = 2, crs = inla.CRS("sphere"))
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
## 3 vertices found in the polygon
inla.over_sp_mesh(obj, mesh, type = "vertex")
#> Error: object 'mesh' not found
## 3 triangles found in the polygon
inla.over_sp_mesh(obj, mesh)
#> Error: object 'mesh' not found
## Multiple transformations can lead to slightly different results due to edge cases
## 4 triangles found in the polygon
inla.over_sp_mesh(obj, inla.spTransform(mesh, CRSobj=inla.CRS("mollweide_norm")), ignore.CRS = FALSE)
#> Error: object 'mesh' not found
## Ignoring mismatching coordinate systems is rarely useful
## 20 triangles "found in" the polygon
inla.over_sp_mesh(obj, inla.spTransform(mesh, CRSobj=inla.CRS("mollweide_norm")), ignore.CRS = TRUE)
#> Error: object 'mesh' not found