Urban | R bloggers

Urban | R bloggers

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report a problem with 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.

Sunset over Rouen, Normandy, France – Public domain by Pierre Blaché

Day 8 of 30 Day Card Challenge: “Urban” (earlier).

French Database of urban units from INSEE.

The concept of an urban unit is based on contiguous built-up areas and population size. Urban units are defined as follows (…): a municipality or group of municipalities with a contiguous built-up area (no distance of more than 200 meters between two buildings) and a population of at least 2,000 inhabitants.

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")

Facts

# 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"))

Card

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")
Map of French urban units

Figure 1: French urban units (2020)


#Urban #bloggers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *