## US example
getUS_map <- function(){
usa <- data.frame(x = state.center$x,
y = state.center$y,
# make the rectangles overlapping by correcting
# lines of longitude distance.
dx = sqrt(state.area) / 2
/ (0.8 * 60 * cos(state.center$y * pi / 180)),
dy = sqrt(state.area) / 2 / (0.8 * 60),
z = sqrt(state.area),
name = state.name)
usa$z <- state.x77[, 'Population']
US.Map <- usa[match(usa$name,
c('Hawaii', 'Alaska'), nomatch = 0) == 0, ]
class(US.Map) <- c('recmap', 'data.frame')
US.Map
}
if (FALSE) {
res <- recmapGRASP(getUS_map())
plot(res$Map, main = "Input Map")
plot(res$Cartogram, main = "Output Cartogram")
}
Run the code above in your browser using DataLab