geo_tiles: Create a regular tiling 'geom'

View source: R/geo_tiles.R

geo_tilesR Documentation

Create a regular tiling geom

Description

Create a regular tiling polygon geometry for the extent of an crds value.

Usage

geo_tiles(
  extent = NULL,
  width = NULL,
  pattern = "squared",
  centroids = FALSE,
  origin = "bottomleft"
)

Arguments

extent

data.frame(2)
Coordinates of the extent within which to build the tiles from. It must include the column names x and y.

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)?

origin

from which of the four corners to start numbering features? Options are topleft, bottomleft (default), topright and bottomright.

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/width 10, because then the y-dimension wouldn't be fully covered. The same is true for hexagonal and triangular tilings.

Value

A geom.

See Also

Other tilings: geo_voronoi()

Examples

# create a squared tiling
tileExt <- data.frame(x = c(-180, 180),
                      y = c(-60, 80))
tiles <- geo_tiles(extent = tileExt, width = 10)
geo_vis(`10° world tiles` = 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 <- geo_polygon(crds = coords, window = window)
geo_vis(`honeycomb background` = aGeom)

hex <- geo_tiles(extent = geomio::getExtent(aGeom), width = 8, pattern = "hexagonal")
geo_vis(hex, linecol = "deeppink", new = FALSE)

EhrmannS/geometr documentation built on Jan. 31, 2024, 9:13 a.m.