Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 

topogram

Cartogram htmlwidget for visualizing geographical data by distorting a TopoJson topology (using cartogram-chart)

Travis build status Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Installation

Install from GitHub:

remotes::install_github("dreamRs/topogram")

Features

Examples

Use a {sf} object as input :

library(rnaturalearth)
library(topogram)

# sf polygons
fr_dept <- ne_states(country = "france", returnclass = "sf")
fr_dept <- fr_dept[fr_dept$type_en %in% "Metropolitan department", ]

# Add a numeric column
fr_dept$foo <- sample.int(100, nrow(fr_dept))

# Create a cartogram
topogram(
  shape = fr_dept, 
  value = "foo"
)

library(rnaturalearth)
library(eurostat)
library(sf)
library(topogram)

# Get polygons
europe <- ne_countries(scale = 50, continent = "europe", returnclass = "sf")
europe <- europe[europe$name %in% eu_countries$name, ]
europe <- st_crop(europe, xmin = -20, ymin = 10, xmax = 35, ymax = 75)
# plot(sf::st_geometry(europe))

# Add a numeric column 
europe$foo <- sample.int(100, nrow(europe))

# Create a cartogram
topogram(
  shape = europe, 
  value = "foo", 
  tooltip_label = ~name, 
  n_iteration = 10, 
  palette = "Blues"
)

Markdown

You can pass several column names, in that case a dropdown menu is added to the widget to select the variable used to distort topology. Use this in markdown to add interactivity.

An example in an R markdown document is availabe here : https://pvictor.github.io/NZ-topogram/ and another one here : https://pvictor.github.io/cartogramme-vin/

Shiny

A proxy method is implemented to update an existing cartogram with classic Shiny inputs.