Consider a map with boundaries such that
- and denote the minimum and maximum longitude of the map, respectively,
- and denote the minimum and maximum latitude of the map, respectively,
- is the total area of the map,
- is the total land area of the map,
- and is the total number of hexagons on even and odd rows respectively,
- and is the total number of hexagons on even and odd columns respectively,
- and are the maximum number of rows and columns in the grid structure,
- is the desired total number of hexagons,
- is the cell size, which is the same as the width of the non-flat topped hexagon.
We assume that the hexagon is not flat topped. Note that , , , , , and are known.
Below is an example where the “map” is a unit square. In this case .
square <- matrix(c(0, 0,
0, 1,
1, 1,
1, 0,
0, 0),
ncol = 2,
byrow = TRUE) %>%
list() %>%
st_polygon()
plot_hex_tile <- function(cellsize = NULL, n = NULL) {
title <- ifelse(is.null(cellsize),
paste0("n = ", n),
paste0("Cell size = ", cellsize))
if(is.null(cellsize)) {
title <- paste0("n = ", n)
grid <- st_make_grid(square, n = n, square = FALSE)
} else {
title <- paste0("Cell size = ", cellsize)
grid <- st_make_grid(square,
cellsize = cellsize,
square = FALSE)
}
ggplot(grid) +
geom_sf(fill = "transparent") +
geom_sf(data = square, fill = "transparent", color = "red") +
ggtitle(title)
}
plot_hex_tile(0.25)
plot_hex_tile(0.3)
plot_hex_tile(0.5)
plot_hex_tile(1)
plot_hex_tile(n = 3)
plot_hex_tile(n = 5)
Using basic trigonometry for a regular hexagon of height , width and length as shown in the diagram below, you can find that and .
Putting it all together, you can find that the maximum and minimum number of hexagons in a row is (even rows) and (odd rows), respectively. The maximum and minimum number of hexagons in a column (which we define as the number of hexagon where its center passes through a vertical line) is and (need to double check this).