The Changing Geography of Output Areas

Output Areas have changed for the 2011 Census; however, the ONS have provided both the Shapefiles and lookup tables indicating how the OA have changed. These require a bit of work to turn them into a map, however, the following code should be reproducible to enable you to create your own maps.

The output of this is a set of PDF maps for each local authority district. Each PDF can be downloaded at the end of the document.

library(rgdal)
library(RColorBrewer)
library("sp")
library(GISTools)

# Set working directory
setwd("/Volumes/Macintosh HD 2/Dropbox/Rpubs/OA_2011")

# Get 2011 lookup
temp <- tempfile(fileext = ".zip")
download.file("http://www.ons.gov.uk/ons/external-links/other-ns-online/census-geography/2001-2011-lookup/oa01-oa11-ew-lu-csv.html", 
    temp)
unzip(temp)
oa_lookup <- read.csv("OA01_OA11_EW_LU.csv")
unlink(temp)

# Get 2011 OA
temp <- tempfile(fileext = ".zip")
download.file("http://www.ons.gov.uk/ons/external-links/other-ns-online/census-geography/2011-oa-boundary/oa-2011-ew-bgc-shp.html", 
    temp)
unzip(temp)
OA <- readOGR(".", "OA_2011_EW_BGC")
unlink(temp)

# Get 2011 MSOA
temp <- tempfile(fileext = ".zip")
download.file("http://www.ons.gov.uk/ons/external-links/other-ns-online/census-geography/2011-msoa-boundary/msoa-2011-ew-bgc-shp.html", 
    temp)
unzip(temp)
MSOA <- readOGR(".", "MSOA_2011_EW_BGC")
unlink(temp)

# Get 2011 OA higher geog lookup
temp <- tempfile(fileext = ".zip")
download.file("http://www.ons.gov.uk/ons/external-links/other-ns-online/census-geography/exact-fit-2011-lookup/oa11-lsoa11-msoa11-lad11-ew-lu-csv.html", 
    temp)
unzip(temp)
oa_higher_lookup <- read.csv("OA11_LSOA11_MSOA11_LAD11_EW_LUv2.csv")
unlink(temp)

# Identify the category of change for 2011 OA
unchanged <- subset(oa_lookup, oa_lookup$CHGIND == "U")
merged <- subset(oa_lookup, oa_lookup$CHGIND == "M")
split <- subset(oa_lookup, oa_lookup$CHGIND == "S")
other <- subset(oa_lookup, oa_lookup$CHGIND == "X")

unchanged_dedup <- subset(unchanged[!duplicated(unchanged$OA11CD), ], select = "OA11CD")
unchanged_dedup$Type <- "U"
merged_dedup <- subset(merged[!duplicated(merged$OA11CD), ], select = "OA11CD")
merged_dedup$Type <- "M"
split_dedup <- subset(split[!duplicated(split$OA11CD), ], select = "OA11CD")
split_dedup$Type <- "S"
other_dedup <- subset(other[!duplicated(other$OA11CD), ], select = "OA11CD")
other_dedup$Type <- "O"

OA_Change_Type <- rbind(unchanged_dedup, merged_dedup, split_dedup, other_dedup)

# Join data onto 2011 OA
OA@data = data.frame(OA@data, OA_Change_Type[match(OA@data[, "OA11CD"], OA_Change_Type[, 
    "OA11CD"]), ])
# Recode Types
OA@data$Type2 <- ifelse(OA@data$Type == "U", 1, ifelse(OA@data$Type == "M", 
    2, ifelse(OA@data$Type == "S", 3, ifelse(OA@data$Type == "O", 4, NA))))

# Join higher geog onto OA
OA@data = data.frame(OA@data, oa_higher_lookup[match(OA@data[, "OA11CD"], oa_higher_lookup[, 
    "OA11CD"]), ])

The following code loops through the local authority districts, creating a PDF for each one.

# Map Colours
my_colours <- brewer.pal(4, "Set2")

# Create LAD list
LAD_LIST <- unique(as.character(OA@data$LAD11CD))

# PDF output
setwd("/Volumes/Macintosh HD 2/Dropbox/Public/RPubsData/PDF/Change")

# Loop through each LAD
for (i in 1:length(LAD_LIST)) {

    LAD <- as.character(LAD_LIST[i])

    OA_to_Map <- OA[OA@data$LAD11CD == LAD, ]
    LAD_NAME <- as.character(OA_to_Map@data[1, "LAD11NM"])
    MSOA_list <- as.character(unique(OA_to_Map@data$MSOA11NM))
    LAD_Outline <- MSOA[MSOA@data$MSOA11NM %in% MSOA_list, ]

    temp <- c(LAD, LAD_NAME)

    # Mapping block
    pdf(paste(LAD, ".pdf", sep = ""), width = 10, height = 10, title = paste(LAD_NAME), 
        paper = "a4")
    plot(OA_to_Map, border = NA, bg = NA, col = NA, axes = FALSE, cex.lab = 0.8, 
        cex.axis = 0.7)
    grid()
    plot(OA_to_Map, border = NA, bg = NA, col = my_colours[OA_to_Map$Type2], 
        axes = FALSE, add = TRUE)
    plot(LAD_Outline, border = "#707070", add = TRUE)
    legend("bottomleft", legend = c("Unchanged", "Merged", "Split", "Other"), 
        fill = my_colours, bty = "n", ncol = 1, bg = FFFFFF)
    mtext("Contains National Statistics data © Crown copyright and database right 2012; Contains Ordnance Survey data © Crown copyright and database right 2012", 
        side = 1, line = 2, cex = 0.5)
    mtext("Map created by Alex Singleton (http://www.alex-singleton.com)", side = 1, 
        line = 1, cex = 0.5)
    title(LAD_NAME)
    dev.off()

}

Download Local Authority District Maps for England and Wales

The following list are links to the local authority district maps.