Home > OS >  Plot a tidy map of English regions
Plot a tidy map of English regions

Time:09-07

I'm trying to plot a tidy map of English regions in R. I'm using code that runs successfully on other shapefiles, but when I run this the code executes without error, but then just presents a blank image. I can plot the blank map using traditional methods, and the tidy object looks fine to me, so I'm at a loss to understand what's going on.

This is the code I'm using:

library(tidyverse)
library(broom)
library(rgdal)

# load and check the English regions map
eng_reg_map <- readOGR(
  dsn = "./Region_(December_2015)_Boundaries"
)

plot(eng_reg_map)

# make a tidy map
tidy_eng_reg_map <- tidy(eng_reg_map, region = "rgn15nm")

# blank map
ggplot()  
  geom_polygon(data = tidy_eng_reg_map, aes(x = long, y = lat, group = group), fill = "white", colour = "black")  
  theme_void()  
  coord_map()

The shapefile I'm using is available enter image description here

Update:

The import is also in this case tidy and allows for a join:

library(dplyr)
library(ggplot2)
library(sf)

eng_reg_map |> 
  left_join(tibble(rgn15nm = c("North East",
                               "North West",
                               "Yorkshire and The Humber",
                               "East Midlands",
                               "West Midlands",
                               "East of England",
                               "London", 
                               "South East",
                               "South West"),
                   pop = seq(1000, 9000, by = 1000))) |>
  ggplot(aes(fill = pop))  
  geom_sf(colour = "black")  
  theme_void()

Output:

enter image description here

  • Related