recmap - Compute the Rectangular Statistical Cartogram
This package implements the RecMap construction algorithm (MP2) using the GA CRAN package as metaheuristic.
1. Installation
use CRAN
recmap
requires R 3.6 or later.
Released and tested versions of recmap
are available via
CRAN,
and can be installed using the following code
install.packages('recmap')
before running R CMD build
and R CMD check
or running the shiny demo execute
pkgs <- c('colorspace', 'doParallel', 'DT', 'knitr', 'maps',
'shiny', 'testthat', 'tufte')
pkgs <- pkgs[(!pkgs %in% unique(installed.packages()[,'Package']))]
if(length(pkgs) > 0){install.packages(pkgs)}
2. Documentation
The package ships with a package
vignette
(browseVignettes('recmap')
)
and a reference manual (just type ?recmap
on the R shell).
Both documents are also available on the package’s
CRAN page.
A white paper containing more technical information and examples is
available through jss.v086.c01.
3. Demonstration
Run an interactive shiny application
library(recmap)
GA::gaControl("useRcpp" = FALSE) # apple M1
recmap_shiny <- system.file('shiny-examples', package = 'recmap')
shiny::runApp(recmap_shiny, display.mode = 'normal')
Run the recmap shiny demonstration as a stand-alone application
using Linux and macOS systems use the Terminal
application add the following
code to your alias file, e.g., $HOME/.bashrc
alias recmapShiny="R -e \"library(shiny); \
recmap_shiny <- system.file('shiny-examples', package = 'recmap'); \
shiny::runApp(recmap_shiny, display.mode = 'normal', launch.browser=TRUE)\""
execute
. $HOME/.bashrc && recmapShiny
4. (Frequently) Asked Questions
4.1 Is there an easy way to convert a recmap
object to an sf
object?
Use as.SpatialPolygonsDataFrame
,
see also issue #13.
The as.recmap
function performs the transformation from a
SpatialPolygonsDataFrame
into a recmap
compatible object.
5. Related approaches
- Rectangular Cartograms: the game, Rectangular Cartograms
- cartogram: Create Cartograms with R https://CRAN.R-project.org/package=cartogram
- Rcartogram
- High-performance software to produce flow-based cartograms.
- see also CRAN Task View: Analysis of Spatial Data
- Computing Stable Demers Cartograms - https://arxiv.org/abs/1908.07291