Created
March 28, 2017 23:13
-
-
Save ashleylester/7ea1c5d13bec301fe7b8ff6bdffa9878 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(rgdal) | |
library(broom) | |
library(dplyr) | |
lad_2016_sg <- readOGR(paste0("data/Local_Authority_Districts_December_2016_Super_Generalised_", | |
"Clipped_Boundaries_in_Great_Britain/Local_Authority_Districts_", | |
"December_2016_Super_Generalised_Clipped_Boundaries_in_Great_", | |
"Britain.shp")) | |
lad_2016_sg <- spTransform(lad_2016_sg, CRS("+init=epsg:4326")) | |
lad_2016_sg@data$id <- rownames(lad_2016_sg@data) | |
lad_2016_sg_ <- tidy(lad_2016_sg) | |
lad_2016_sg <- lad_2016_sg@data %>% | |
transmute(id = id, | |
lad16cd = as.character(lad16cd), | |
lad16nm = as.character(lad16nm)) %>% | |
inner_join(lad_2016_sg_, by = "id") | |
lad_2016_sg <- readOGR(paste0("data/Local_Authority_Districts_December_2016_Super_Generalised_", | |
"Clipped_Boundaries_in_Great_Britain/Local_Authority_Districts_", | |
"December_2016_Super_Generalised_Clipped_Boundaries_in_Great_", | |
"Britain.shp")) | |
lad_2016_sg <- spTransform(lad_2016_sg, CRS("+init=epsg:4326")) | |
lad_2016_sg@data$id <- rownames(lad_2016_sg@data) | |
lad_2016_sg_ <- tidy(lad_2016_sg) | |
lad_2016_sg <- lad_2016_sg@data %>% | |
transmute(id = id, | |
lad16cd = as.character(lad16cd), | |
lad16nm = as.character(lad16nm)) %>% | |
inner_join(lad_2016_sg_, by = "id") | |
la_to_ctry_2016 <- read.csv("data/Local_Authority_District_to_Country_December_2016_Lookup_in_the_United_Kingdom.csv", | |
stringsAsFactors = FALSE) | |
devtools::use_data(la_to_ctry_2016) | |
test <- inner_join(lad_2016_sg, la_to_ctry_2016, by = "lad16cd") | |
test <- test %>% filter(ctry16nm %in% c("England", "Wales")) | |
ggplot(test, aes(long, lat)) + geom_polygon(aes(group = group), color = "white", size = 0.2) + coord_quickmap() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment