addBoundary: Embed matrix within larger matrix

Description Usage Arguments Value Author(s) References See Also Examples

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

1
addBoundary(pop, sea = 2, land.mean = mean(unlist(pop)))

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.

land.mean

the scalar value that we use as the value for the cells we with which we surround the existing matrix. This is the value for all the cells in the sea region.

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

1
2
3
4
5
6
7
8
9
 m = matrix(1, 5, 7)
 mm = col(m)

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

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

omegahat/Rcartogram documentation built on May 24, 2019, 1:55 p.m.