fm_hexagon_lattice | R Documentation |
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
)
bnd |
Boundary object (currently must be an |
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 |
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
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]]))
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.