library(tidyverse)
library(sf)
library(glue)
library(ggspatial)
library(ggrepel)
library(rnaturalearth)
set.seed(4326)
# final projection
<- "EPSG:2154"
map_proj
# cities (randomized)
<- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
pref layer = "commune") |>
filter(insee_reg > "06",
str_detect(statut, "Préfecture de région|Capitale")) |>
mutate(nom = sample(nom)) |>
st_point_on_surface()
# départements
<- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
fr layer = "departement") |>
filter(insee_reg > "06") |>
st_transform(map_proj)
# basemap
<- ne_countries(50, returnclass = "sf") |>
countries filter(admin != "France",
== "Europe") continent
Day 10 of 30DayMapChallenge: « bad map » (previously).
Just resampling…
|>
fr ggplot() +
geom_sf(data = countries, color = "grey20", fill = "grey12") +
geom_sf(color = "grey", fill = "lightgrey") +
geom_sf(data = pref, color = "black", size = 1) +
geom_text_repel(data = pref,
aes(label = nom, geometry = geom),
stat = "sf_coordinates",
size = 3,
bg.color = "#ffffff66",
bg.r = 0.2 ) +
coord_sf(xlim = st_bbox(fr)[c(1, 3)],
ylim = st_bbox(fr)[c(2, 4)],
crs = map_proj) +
labs(title = "France métropolitaine",
subtitle = "Get lost",
x = "",
y = "",
caption = glue("data : based on IGN Adminexpress
proj.: {format(st_crs(map_proj))}
r.iresmi.net - {Sys.Date()}")) +
theme(plot.background = element_rect(fill = "grey10", color = NA),
panel.background = element_rect(fill = "grey10", color = NA),
panel.grid = element_line(color = "grey15"),
plot.title = element_text(color = "grey90", family = "Waree"),
plot.subtitle = element_text(color = "grey90"),
plot.caption = element_text(color = "grey60", size = 6))