Site icon R-bloggers

Scales

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Scale rulers – © by Frank

Day 12 of 30DayMapChallenge: « scales » (previously).

French « départements » at the same size but tidily ordered by area, using data from Adminexpress made in Simplifying polygons layers.

library(tidyverse)
library(sf)
library(units)
library(tmap)

"~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg" |> 
  read_sf(layer = "departement") |> 
  filter(!is.na(nom)) |> 
  mutate(surf_km2 = set_units(st_area(geom), km^2), 
         rank = dense_rank(surf_km2), 
         nom_dep = fct_rev(fct_reorder(as_factor(nom), rank))) |> 
  tm_shape() +
  tm_polygons(fill = "lightgrey") +
  tm_facets(by = "nom_dep", free.scales = TRUE)

Figure 1: Départements
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version