The popcircle package

The popcircle package has been released on GitHub. This one-function package computes circles with areas scaled to a variable and displays them using a compact layout (higher values in the center, lower values at the periphery). Original polygons are scaled to fit inside these circles (size are roughly proportional, not strictly).

The circles creation relies on packcircles, spatial data manipulation relies on sf.

## Package install:
library(remotes)
install_github("rCarto/popcircle")

This is a typical example of the package usage based on the dataset shipped with the package. We use cartography to display labels.

library(sf)
library(popcircle)
library(cartography)
mtq <- st_read(system.file("gpkg/mtq.gpkg", 
                           package="popcircle"))
res <- popcircle(x = mtq, var = "POP")
circles <- res$circles
shapes <- res$shapes
par(mar = c(0,0,0,0))
plot(st_geometry(circles), col = "#bcd39c", 
     border = "white", bg = "#eafdcf")
plot(st_geometry(shapes), col = "#fffc99", 
     border = "#fffc99", add = TRUE)
labelLayer(x = circles[1:20,], txt = "LIBGEO",
           halo = TRUE, col ="#8e8358", 
           cex = seq(.8,.4, length.out = 20),
           font = 2, bg = "white", r = .15, 
           overlap = FALSE)

The next example was a bit more difficult to design. We had to work on some multipolygons countries (e.g. France, USA or Russia) in order to keep only the largest polygon.

Code for the figure
Code for the figure

As popcircle produces sf objects it is possible to display them interactively:

You can find here an example of interactive visualisation using leaflet.

popcircle changes the position of spatial units. It will work better with regions already well known to the target audience. Chances are that the first figure on Martinique municipalities will be more appropriate and effective for the inhabitants of Martinique.


OpenEdition vous propose de citer ce billet de la manière suivante :
Timothée Giraud (5 avril 2019). The popcircle package. R Géomatique. Consulté le 7 septembre 2024 à l’adresse https://doi.org/10.58079/tp4i


2 réflexions sur « The popcircle package »

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.