Guest User

Untitled

a guest
Jan 23rd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. # install dev version of ggplot2
  2. devtools::dev_mode()
  3. devtools::install_github("tidyverse/ggplot2")
  4.  
  5. library(tidyverse)
  6. library(sf)
  7. library(rmapshaper)
  8. library(ggthemes)
  9.  
  10.  
  11. # load data
  12. source(file = url("https://gist.githubusercontent.com/ikashnitsky/4b92f6b9f4bcbd8b2190fb0796fd1ec0/raw/1e281b7bb8ec74c9c9989fe50a87b6021ddbad03/minimal-data.R"))
  13.  
  14. # test how good they fit together
  15. ggplot() +
  16. geom_sf(data = REG, color = "black", size = .2, fill = NA) +
  17. geom_sf(data = NEI, color = "red", size = .2, fill = NA)+
  18. coord_sf(datum = NA)+
  19. theme_map()
  20.  
  21. ggsave("test-1.pdf", width = 12, height = 10)
  22.  
  23. # simplify
  24. REGs <- REG %>% ms_simplify(keep = .5, keep_shapes = TRUE)
  25. NEIs <- NEI %>% ms_simplify(keep = .5, keep_shapes = TRUE)
  26.  
  27.  
  28. ggplot() +
  29. geom_sf(data = REGs, color = "black", size = .2, fill = NA) +
  30. geom_sf(data = NEIs, color = "red", size = .2, fill = NA)+
  31. coord_sf(datum = NA)+
  32. theme_map()
  33.  
  34. ggsave("test-2.pdf", width = 12, height = 10)
Add Comment
Please, Sign In to add comment