Skip to content

Instantly share code, notes, and snippets.

@uribo
Created June 6, 2024 08:24
Show Gist options
  • Save uribo/695e2d734e45b0ad68d0236c86f5e9b9 to your computer and use it in GitHub Desktop.
Save uribo/695e2d734e45b0ad68d0236c86f5e9b9 to your computer and use it in GitHub Desktop.
四国、徳島県をハイライトさせる地図
library(dplyr)
library(sf)
d <-
fs::dir_ls("~/Documents/resources/国土数値情報/N03/2024/",
regexp = "(36|37|38|39).geojson$",
recurse = TRUE) |>
purrr::set_names(c(zipangu::jpnprefs |>
filter(jis_code %in% as.character(c(36, 37, 38, 39))) |>
pull(prefecture_kanji))) |>
purrr::map(
\(x) sf::st_read(x) |>
sf::st_make_valid() |>
summarise() |>
sfheaders::sf_remove_holes()
) |>
purrr::list_rbind(names_to = "prefecture") |>
sf::st_as_sf()
mapview::mapview(d)
library(ggplot2)
ggplot2::ggplot() +
ggplot2::geom_sf(data = d |>
filter(prefecture != "徳島県"),
fill = "gray80",
alpha = 0.1) +
geom_sf(data = d |>
filter(prefecture == "徳島県"),
fill = "#0F1347") +
ggplot2::theme_void()
# ggplot2::ggsave("shikoku_tokushima.png", width = 10, height = 6, dpi = 300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment