generate_map {tilemaps}R Documentation

Generate a Single Tile Map

Description

Generate a single square or hexagon tile map.

Usage

generate_map(
  data,
  square = TRUE,
  flat_topped = FALSE,
  prop = 0,
  interpolate = 1,
  smoothness = 0,
  shift = c(0, 0)
)

Arguments

data

An object of class sfc_MULTIPOLYGON or sfc_POLYGON, which contains the regions that make up the original map.

square

logical. If TRUE, generates a square tile map. If FALSE, generates a hexagon tile map.

flat_topped

logical. If TRUE, hexagons are flat-topped. If FALSE, hexagons are pointy-topped.

prop

A proportion used in specifying the standard deviation of the Gaussian noise added to original region centroids. The standard deviation of the Gaussian noise is calculated as the mean distance between a region centroid and its neighboring regions' centroids multiplied by the value provided for the prop argument.

interpolate

A number between 0 and 1 controlling the linear interpolation between the noisy region centroids and fully-transformed region centroids. If 0, noisy region centroids are used. If 1, fully-transformed centroids are used.

smoothness

numeric. Controls the bandwidth of the Gaussian kernel used for smoothing the transformed boundary polygon. The bandwidth is calculated as the mean distance between adjacent boundary points multiplied by the value provided for the smoothness argument.

shift

A numeric vector of length two specifying the number of grid steps to shift the candidate tile map in the x and y directions before counting the number of tile centroids that lie within the transformed boundary.

Details

Implements an algorithm for generating tile maps proposed in "Generating Tile Maps" (McNeill and Hale 2017). The regions of the map must be contiguous. Coordinates cannot be in terms of latitude and longitude. Instead the coordinate reference system must be an appropriate planar projection.

Value

Returns an object of class sfc_POLYGON, containing the tiles of the tile map in the same order as the original regions given to the function.

References

McNeill, Graham, and Scott A Hale. 2017. “Generating Tile Maps.” In Computer Graphics Forum, 36:435–45. 3. Wiley Online Library.

Examples

library(sf)
northeast <- governors[c(6,7,17,18,19,27,28,30,36,37,43),]
northeast$tile_map <- generate_map(northeast$geometry, square = FALSE,
                                   flat_topped = TRUE)


[Package tilemaps version 0.2.0 Index]