if (TRUE &&
fm_safe_sp()) {
# Create a polygon and a mesh
obj <- sp::SpatialPolygons(
list(sp::Polygons(
list(sp::Polygon(rbind(
c(0, 0),
c(50, 0),
c(50, 50),
c(0, 50)
))),
ID = 1
)),
proj4string = fm_CRS("longlat_globe")
)
mesh <- fm_rcdt_2d_inla(globe = 2, crs = fm_crs("sphere"))
## 3 vertices found in the polygon
fm_contains(obj, mesh, type = "vertex")
## 3 triangles found in the polygon
fm_contains(obj, mesh)
## Multiple transformations can lead to slightly different results
## due to edge cases:
## 4 triangles found in the polygon
fm_contains(
obj,
fm_transform(mesh, crs = fm_crs("mollweide_norm"))
)
}
Run the code above in your browser using DataLab