Urban
[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.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Day 8 of 30DayMapChallenge: « Urban » (previously).
French Urban unit database from INSEE.
The concept of an urban unit is based on continuous built-up areas and population size. Urban units are defined (…) as follows: a municipality or group of municipalities with a continuous built-up area (no gap of more than 200 meters between two buildings) and a population of at least 2,000.
library(sf)
library(dplyr)
library(ggplot2)
library(glue)
library(ggspatial)
library(ggokabeito)
# move DROM
# we use a function defined previously
source(glue("../../2023/where_and_when_not_to_eat_in_france/translation.R"),
encoding = "UTF-8")
Data
# administrative units
# https://r.iresmi.net/posts/2021/simplifying_polygons_layers/results/adminexpress_simpl_2022.zip
reg <- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
layer = "region") |>
translater_drom(type = "reg")
dep <- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
layer = "departement")
# Get the data directly from INSEE
download.file("https://www.insee.fr/fr/statistiques/fichier/4802589/fonds_uu2020_2025.zip",
"fonds_uu2020_2025.zip")
unzip("fonds_uu2020_2025.zip")
unzip("fonds_uu2020_2025/uu2020_2025.zip")
unlink("fonds_uu2020_2025", recursive = TRUE)
uu <- read_sf("uu2020_2025.shp") |>
st_join(dep, largest = TRUE) |>
translater_drom() |>
mutate(type_en = case_match(type,
"Agglomération inter-départementale" ~
"Interdepartmental agglomeration",
"Agglomération inter-régionale" ~
"Interregional agglomeration",
"Agglomération internationale" ~
"International agglomeration",
"Agglomération intra-départementale" ~
"Intradepartmental agglomeration",
"Ville isolée ou unité urbaine monocommunale" ~
"Isolated city or single-municipality urban unit"))
Map
uu |>
ggplot() +
geom_sf(data = reg, fill = "#f0f0f0", color = "grey") +
geom_sf(aes(color = type_en, fill = type_en)) +
scale_color_okabe_ito() +
scale_fill_okabe_ito() +
guides(fill = guide_legend(ncol = 2),
color = guide_legend(ncol = 2)) +
labs(title = "Urban units",
subtitle = "France",
fill = "type",
color = "type",
caption = glue("https://r.iresmi.net/ - {Sys.Date()}
data: INSEE 2020 (2025 edition) & IGN Admin Express 2022")) +
annotation_scale(height = unit(1, "mm"), bar_cols = c("white", "grey")) +
theme_void() +
theme(plot.caption = element_text(size = 6,
color = "darkgrey"),
legend.position = "bottom")
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.