Commit dc230ea2 authored by Ronan Ysebaert's avatar Ronan Ysebaert
Browse files

add maps to explain global methodology

parent 1d7fcfa3
Pipeline #10004 passed with stage
in 1 minute and 4 seconds
library(sf)
library(readxl)
library(mapsf)
library(osmdata)
hop <- st_read(dsn = "data/geom.gpkg", layer = "hop", quiet = TRUE)
com_dist <- st_read(dsn = "data/geom.gpkg", layer = "com_dist", quiet = TRUE)
chefL <- st_read('data-raw/geom/CHEF_LIEU.shp', quiet = TRUE)
dep <- st_read(dsn = "data/geom.gpkg", layer = "dep", quiet = TRUE)
fr <- st_union(dep)
# Create template
bb <- c(xmin = 920000, ymin = 6330000, xmax = 970000, ymax = 6360000)
# bbox de la zone d'étude
bbox00 <- st_as_sfc(st_bbox(bb, crs = 2154))
bbox <- st_as_sfc(st_bbox(bb + c(-5000,-5000,5000,5000), crs = 2154))
# Intersection
hop <- st_intersection(hop, bbox00)
com_dist <- st_intersection(com_dist, bbox00)
chefL <- st_intersection(chefL, bbox00)
# OSM
cc <- st_transform(bbox00,4326)
bb <- st_bbox(cc)
# define a bounding box
q0 <- opq(bbox = bb)
# extract le Rhône
q1 <- add_osm_feature(opq = q0, key = 'name', value = "La Durance")
res1 <- osmdata_sf(q1)
river <- st_geometry(res1$osm_lines)
q4 <- add_osm_feature(q0, key = 'highway', value = c("motorway", "trunk", "primary", "secondary", "tertiary", " unclassified", "residential"), value_exact = FALSE)
roads <- osmdata_sf(q4)$osm_lines
roads <- roads[,"highway"]
roads <- roads[roads$highway %in% c("motorway", "trunk", "primary", "secondary", "tertiary", "unclassified", "residential"),]
river <- st_transform(river, 2154)
roads <- st_transform(roads, 2154)
river <- st_intersection(river, bbox00)
roads <- st_intersection(roads, bbox00)
hop00 <- hop[hop$year == "2000",]
hop18 <- hop[hop$year == "2018",]
# Map 1 - Origins / destination
theme_perso <- list(bg = "white", fg = NA, mar = c(1.2, 0, 1.2, 0), tab = TRUE, pos = "left",
inner = TRUE, line = 1.3, cex = 1, font = 2)
mf_export(bbox00, export = "png", file = "fig/method/01_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_map(com_dist, col = "white", border = "black", add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop00, bg = "darkgreen", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop00, var = "LIBCOM", halo = TRUE)
mf_inset_on(x = fr, pos = "topright")
mf_map(fr, border = NA)
mf_map(chefL[1, ], cex = 1.5, pch = 21, bg = "red", add = TRUE)
mf_map(st_as_sfc(st_bbox(fr, crs = 2154)), col = NA, border = "black", add = TRUE)
mf_inset_off()
mf_legend(type = "symb", pt_cex = c(.6, 2), pt_pch = c(21,24), title = "Two input-layers",
pal = c("black", "darkgreen"), pos = "topleft1", bg = "#ffffff80", frame = TRUE,
val = c("Origins : Municipilaties town halls (35 200 points in France)",
"Destinations : Hospitals with surgical beds (1280 points in 2000)"))
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "01 - Origins - destinations calculation in 2000", fg = "white", bg = "black")
dev.off()
# Map 2 - OSM roads
mf_export(bbox00, export = "png", file = "fig/method/02_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_map(com_dist, col = "white", border = "black", add = TRUE)
mf_typo(
x = roads, var = "highway", pal = c("#e31a1c", "#fd8d3c", "#fecc5c", "grey", "lightgrey"), lwd = c(1, .8, .6, .4, .2),
val_order = c("motorway", "primary", "secondary", "tertiary", "residential"),
leg_pos = "n", add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop00, bg = "red3", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop00, var = "LIBCOM", halo = TRUE)
mf_legend(type = "typo", val = c("motorway", "primary", "secondary", "tertiary", "residential"),
pal = c("#e31a1c", "#fd8d3c", "#fecc5c", "grey", "lightgrey"),
pos = "topleft1", bg = "#ffffff80", frame = TRUE, title = "OSM roads")
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "02 - Travel - time calculation by road (osrm)", fg = "white", bg = "black")
dev.off()
# Map 3
mf_export(bbox00, export = "png", file = "fig/method/03_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_choro(
x = com_dist, var = "DIST1_ALL_2000", breaks = c(min(com_dist$DIST1_ALL_2000), 15, 30, 45, max(com_dist$DIST1_ALL_2000)),
leg_pos = "n", leg_frame = TRUE, border = "black", pal = rev(hcl.colors(4, palette = "BluYl")),
add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(roads, col = "lightgrey", cex = .2, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop00, bg = "red3", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop00, var = "LIBCOM", halo = TRUE)
mf_legend(type = "choro", val = c(min(com_dist$DIST1_ALL_2000), 15, 30, 45, max(com_dist$DIST1_ALL_2000)),
title = "Time by road, in minutes\n(calculated via osrm)", pos = "topleft1", bg = "#ffffff80", frame = TRUE,
pal = rev(hcl.colors(4, palette = "BluYl")))
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "03 - Time to reach the nearest hospital in 2000", fg = "white", bg = "black")
dev.off()
# Map 4
mf_export(bbox00, export = "png", file = "fig/method/04_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_map(com_dist, col = "white", border = "black", add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(roads, col = "lightgrey", cex = .2, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop00, bg = "red3", border = NA, pch = 24, cex = 2, add = TRUE)
mf_map(hop18, bg = "darkgreen", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop00, var = "LIBCOM", halo = TRUE)
mf_legend(type = "symb", pt_cex = c(.6, 2, 2), pt_pch = c(21,24, 24), title = "Two input-layers",
pal = c("black", "red3", "darkgreen"), pos = "topleft1", bg = "#ffffff80", frame = TRUE,
val = c("Origins : Municipilaties town halls (35 200 points in France)",
"Hospital closed (difference 2018 - 2000 : 367)",
"Hospital still open in 2018 (913 points)"))
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "04 - Origins - destinations calculation in 2018", fg = "white", bg = "black")
dev.off()
# Map 5
mf_export(bbox00, export = "png", file = "fig/method/05_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_choro(
x = com_dist, var = "DIST1_ALL_2018", breaks = c(min(com_dist$DIST1_ALL_2018), 15, 30, 45, max(com_dist$DIST1_ALL_2018)),
leg_pos = "n", leg_frame = TRUE, border = "black", pal = rev(hcl.colors(4, palette = "BluYl")),
add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(roads, col = "lightgrey", cex = .2, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop18, bg = "darkgreen", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop18, var = "LIBCOM", halo = TRUE)
mf_legend(type = "choro", val = c(min(com_dist$DIST1_ALL_2000), 15, 30, 45, max(com_dist$DIST1_ALL_2000)),
title = "Time by road, in minutes\n(calculated via osrm)", pos = "topleft1", bg = "#ffffff80", frame = TRUE,
pal = rev(hcl.colors(4, palette = "BluYl")))
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "05 - Time to reach the nearest hospital in 2018", fg = "white", bg = "black")
dev.off()
# Map 6
com_dist$EVOL <- com_dist$DIST1_ALL_2018 - com_dist$DIST1_ALL_2000
cols <- c("lightgreen", "#FCE581", "#FCC661", "#FE8019", "#F80000")
mf_export(bbox00, export = "png", file = "fig/method/06_method.png", height = 1200, res = 200,
theme = theme_perso, expandBB = c(0.01,-0.03, 0.005,-0.03))
mf_choro(
x = com_dist, var = "EVOL", breaks = c(min(com_dist$EVOL), 1, 5, 15, 30, max(com_dist$EVOL)),
leg_pos = "n", leg_frame = TRUE, border = "black", pal = cols,
add = TRUE)
mf_map(river, col = "#AAD3DF", lwd = 4, add = TRUE)
mf_map(roads, col = "lightgrey", cex = .2, add = TRUE)
mf_map(chefL, bg = "black", pch = 21, cex = .6, add = TRUE)
mf_map(hop00, bg = "red3", border = NA, pch = 24, cex = 2, add = TRUE)
mf_map(hop18, bg = "darkgreen", border = NA, pch = 24, cex = 2, add = TRUE)
mf_label(hop18, var = "LIBCOM", halo = TRUE)
mf_legend(type = "choro", val = c(min(com_dist$EVOL), 1, 5, 15, 30, max(com_dist$DIST1_ALL_2000)),
title = "Difference 2000-2018,\nin minutes\n(constant network)", pos = "topleft1", bg = "#ffffff80", frame = TRUE,
pal = cols)
mf_scale(5, pos = "bottomright", col = "black")
mf_credits("Sources : OpenStreetMap and contributors, OSRM, INSEE, IGN, Authors (hospitals database), 2021\nRealisation : Ronan Ysebaert, 2022",
cex = .5)
mf_title(txt = "06 - Accessibility evolution 2000-2018", fg = "white", bg = "black")
dev.off()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment