Inaccessibility
[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 7 of 30DayMapChallenge: « Accessibility » (previously).
Well, let us be rebellious and instead seek inaccessibility; more precisely the pole of inaccessibility of France (the Hexagon): the farthest location from the boundary. Not to be confused with the centroid.
library(sf) library(dplyr) library(ggplot2) library(glue) library(purrr) library(polylabelr)
Data
We’ll use again the french administrative units (get the data from this post).
# France boundary
fr <- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
layer = "region") |>
filter(insee_reg > "06",
insee_reg != "94") |>
st_transform("EPSG:2154") |>
st_union()
# French communes to get the point name
com <- read_sf("~/data/adminexpress/adminexpress_cog_simpl_000_2022.gpkg",
layer = "commune") |>
filter(insee_reg > "06",
insee_reg != "94") |>
st_transform("EPSG:2154")
Compute the POI
Get the inaccessibility pole of France with {polylabelr} and intersects with the commune layer to find the nearest city.
fr_poi <- poi(fr) |>
pluck(1) |>
as_tibble() |>
st_as_sf(coords = c("x", "y"), crs = "EPSG:2154") |>
st_join(com)
fr_poi_circle <- fr_poi |>
mutate(geometry = st_buffer(geometry, dist))
fr_centroid <- fr |>
st_centroid()
It seems to be in Saint-Palais in the Cher département.
Map
fr_poi |>
ggplot() +
geom_sf(data = fr) +
geom_sf(data = fr_poi_circle, linewidth = 1, linetype = 3) +
geom_sf(data = fr_centroid, color = "darkgrey") +
geom_sf() +
geom_sf_text(aes(label = nom), vjust = -.5) +
labs(title = "Pole of inaccessibility",
subtitle = "France",
x = "", y = "",
caption = glue("https://r.iresmi.net/ - {Sys.Date()}
data from IGN Adminexpress 2022")) +
theme_minimal() +
theme(plot.caption = element_text(size = 6,
color = "darkgrey"))
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.