addBoundary {Rcartogram}R Documentation

Embed matrix within larger matrix

Description

This function is useful for taking the grid of densities/counts as a matrix and embedding it in a larger matrix whose additional values are just the mean of our original matrix. This new matrix can then be handed to cartogram to fit the diffusion cartogram. The extra "padding" or "sea" helps the algorithm converge.

Usage

addBoundary(pop, sea = 0.2)

Arguments

pop the matrix of densities/counts to be embedded.
sea a number which is applied to the dimensions of the original matrix to determine how many rows and columns should be added to the original matrix. Twice as many rows and columns are added as this product, an equal number of rows above and below, and an equal number of columns to the left and to the right.

Value

A matrix with dimension floor((1 + 2 * seq) * dim(pop)) and whose "outer" values in the added rows is the mean of the original matrix pop.

Author(s)

Duncan Temple Lang created the interface for R

References

"Diffusion-based method for producing density equalizing maps", Michael T. Gastner and M. E. J. Newman, Proc. Natl. Acad. Sci. USA 101, 7499-7504 (2004) http://www.pnas.org/cgi/content/abstract/101/20/7499

See Also

cartogram

Examples


 m = matrix(1, 5, 7)
 mm = col(m)

 ex = addBoundary(mm)
 dim(ex)
 image(ex)

 ex = addBoundary(mm, 1)
 dim(ex)

[Package Rcartogram version 0.2-2 Index]