Created
October 11, 2019 13:29
-
-
Save uribo/73cee26a37e66f620bb633f6dca9f12e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(fgdr) | |
library(purrr) | |
library(sf) | |
library(h3forr) | |
library(ggplot2) | |
sf_hex <- | |
geo_to_h3(c(36.0670602, 140.0781036), res = 7) %>% | |
h3_to_geo_boundary() %>% | |
geo_boundary_to_sf() | |
df_merge <- | |
fs::dir_ls("~/Downloads/PackDLMap-2/FG-GML-544000-ALL-20190401", | |
recurse = TRUE, | |
regexp = "FG-GML-544000-ALL-20190401/FG-GML.+.xml") %>% | |
map( | |
~ read_fgd(.x) %>% | |
st_transform(crs = 4326) %>% | |
st_intersection(sf_hex)) %>% | |
set_names(basename(files)) %>% | |
map( | |
~ dplyr::filter(.x, org_gi_level == 2500, visibility != "非表示") | |
) %>% | |
keep(~ nrow(.) > 0) | |
df_merge <- | |
df_merge %>% | |
map( | |
~ dplyr::select(.x, gml_id, type)) | |
df_select <- | |
rbind(df_merge[[1]], df_merge[[3]]) %>% | |
rbind(df_merge[[5]]) %>% | |
rbind(df_merge[[6]]) | |
ggplot() + | |
geom_sf(data = sf_hex, fill = "#FFFFFF") + | |
geom_sf(data = df_merge[[4]], color = "#FBE9C9", fill = "#FBE9C9") + | |
geom_sf(data = df_merge[[14]], color = "#C2D2FB", fill = "#C2D2FB") + | |
geom_sf(data = df_select[[3]], color = "#666666", size = 1.2) + | |
geom_sf(data = df_select[[4]], color = "gray") + | |
geom_sf(data = df_select[[5]], color = "#F3F251", fill = "#F3F251") + | |
geom_sf(data = df_select[[1]], color = "#422281", size = 0.1, linetype = "dashed") + | |
coord_sf(datum = NA) + | |
geom_sf(data = st_sfc(st_point(c(140.0781036, 36.0670602)), crs = 4326), color = "red") + | |
guides(color = FALSE, fill = FALSE) | |
ggsave("icon.png", plot = last_plot(), width = 7, height = 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment