
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.
fm_hexagon_lattice(
bnd,
edge_len = NULL,
buffer_n = 0.49,
align = "origin",
meta = FALSE
)
An sfc
object with points, if meta
is FALSE
(default), or if
meta=TRUE
, a list:
sfc
with lattice points
numeric
with edge length
sf
object with the inner boundary used to filter points
outside of a edge_len * buffer_n
distance from the boundary
integer
with the number of points in each direction prior to
filtering
numeric
with the alignment coordinates of the hexagon lattice
Boundary object (currently must be an sf
polygon)
Triangle edge length. Default diff(fm_bbox(bnd)[[1]]) / 250
.
Number of triangle height multiples for buffer inside the boundary object to the start of the lattice. Default 0.49.
Alignment of the hexagon lattice, either a length-2 numeric, or
character, a sf
/sfc
/sfg
object containing a single point), or
character
, default "origin"
:
align the lattice with the coordinate system origin
align the lattice with the midpoint of the bounding box of
bnd
align the lattice with the centroid of the boundary,
sf::st_centroid(bnd)
logical; if TRUE
, return a list with diagnostic information
from the lattice construction (including the points themselves in lattice
)
Man Ho Suen M.H.Suen@sms.ed.ac.uk, Finn Lindgren Finn.Lindgren@gmail.com
fm_mesh_2d()
(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]]))
)
)
}
Run the code above in your browser using DataLab