fm_hexagon_lattice {fmesher} | R Documentation |
Create hexagon lattice points
Description
from
0.3.0.9001
. Create
hexagon lattice points within a boundary. By default, the hexagonal lattice
is anchored at the coordinate system origin, so that grids with different
but overlapping boundaries will have matching points.
Usage
fm_hexagon_lattice(
bnd,
edge_len = NULL,
buffer_n = 0.49,
align = "origin",
meta = FALSE
)
Arguments
bnd |
Boundary object ( |
edge_len |
Triangle edge length. Default |
buffer_n |
Number of triangle height multiples for buffer inside the boundary object to the start of the lattice. Default 0.49. |
align |
Alignment of the hexagon lattice, either a length-2 numeric, or
character, a
|
meta |
logical; if |
Value
An sfc
object with points, if meta
is FALSE
(default), or if
meta=TRUE
, a list:
- lattice
sfc
with lattice points- edge_len
numeric
with edge length- bnd_inner
sf
object with the inner boundary used to filter points outside of aedge_len * buffer_n
distance from the boundary- grid_n
integer
with the number of points in each direction prior to filtering- align
numeric
with the alignment coordinates of the hexagon lattice
Author(s)
Man Ho Suen M.H.Suen@sms.ed.ac.uk, Finn Lindgren Finn.Lindgren@gmail.com
See Also
Examples
(m <- fm_mesh_2d(
fm_hexagon_lattice(
fmexample$boundary_sf[[1]],
edge_len = 0.1 * 5
),
max.edge = c(0.2, 1) * 5,
boundary = fmexample$boundary_sf
))
(m2 <- fm_mesh_2d(
fm_hexagon_lattice(
fmexample$boundary_sf[[1]],
edge_len = 0.1 * 5,
align = "centroid"
),
max.edge = c(0.2, 1) * 5,
boundary = fmexample$boundary_sf
))
if (require("ggplot2", quietly = TRUE) &&
require("patchwork", quietly = TRUE)) {
((ggplot() +
geom_fm(data = m) +
geom_point(aes(0, 0), col = "red")) |
(ggplot() +
geom_fm(data = m2) +
geom_point(aes(0, 0), col = "red") +
geom_sf(data = sf::st_centroid(fmexample$boundary_sf[[1]]))
)
)
}