Learn R Programming

geometr (version 0.2.5)

gs_tiles: Create a regular tiling geom

Description

Create a regular tiling polygon geometry (of class geom) for the extent of an anchor value.

Usage

gs_tiles(
  anchor = NULL,
  width = NULL,
  pattern = "squared",
  centroids = FALSE,
  ...
)

Arguments

anchor

[geom(1)|data.frame(1)] Object to derive the tiling geom from. It must include column names x, y and optionally a custom fid.

width

[numeric(1)] the width (which does not correspond to the height in case of pattern = "hexagonal") of a tile.

pattern

[character(1)] pattern of the tiling. Possible options are "squared" (default) or "hexagonal".

centroids

[logical(1)] should the centroids of the tiling be returned (TRUE) or should the tiling be returned (FALSE, default)?

...

[various] additional arguments; see Details.

Value

An invisible geom.

Details

When deriving a regular tiling for a prescribed window, there is only a limited set of legal combinations of cells in x and y dimension. For instance, a window of 100 by 100 can't comprise 10 by 5 squares of side-length 10, because then the y-dimension wouldn't be fully covered. The same is true for hexagonal and triangular tilings. As all tilings are regular, the measurement of one dimension is sufficient to specify the dimensions of tiles, which is width.

Possible additional arguments are:

  • verbose = TRUE/FALSE

  • graphical parameters to gt_locate, in case points are sketched; see gpar

See Also

Other tilings: gs_voronoi()

Examples

Run this code
# NOT RUN {
# create a squared tiling
library(magrittr)
aWindow <- data.frame(x = c(-180, 180),
                      y = c(-60, 80))
gs_tiles(anchor = aWindow, width = 10) %>%
  visualise(`10<U+00B0> world tiles` = .)

# create a hexagonal tiling on top of a geom
coords <- data.frame(x = c(40, 70, 70, 50),
                     y = c(40, 40, 60, 70))
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
aGeom <- gs_polygon(anchor = coords, window = window)
visualise(`honeycomb background` = aGeom)
gs_tiles(anchor = aGeom, width = 8, pattern = "hexagonal") %>%
  visualise(., linecol = "deeppink", new = FALSE)
# }

Run the code above in your browser using DataLab