Skip to contents

Overview

ukgeog is a simple package to facilitate the easy download of official spatial data sets of the UK. It includes a wide range of geospatial data, provided as simple feature sf objects (like shapefiles but better). Making it easy to make Choropleth Maps with base R, as well as with popular packages such as ggplot2 and leaflet.

Other functions are provided to create UK Local Authority (LA) lookups, across time and between lower and upper tiers.

Installation

# install.packages("remotes")
remotes::install_github("l-hodge/ukgeog")

Downloading UK boundaries from the ONS

  • available_sf returns a list of available boundaries

  • select_sf can be used to interactively select a set of boundaries to download

  • read_sf can be used to download boundaries for the following geographies using the ‘geog’ and ‘year’ arguments:

‘geog’ Geography Year
UTLA Counties and Unitary Authorities 2018; 2019; 2020; 2021
NAT Countries 2018; 2019; 2020; 2021
EU European Electoral Regions 2018
LAD Local Authority Districts 2018; 2019; 2020; 2021
LSOA Lower Super Output Areas 2001; 2011
MSOA Middle Super Output Areas 2001; 2011
WAC National Assembly for Wales Constituencies 2018
WAR National Assembly for Wales Electoral Regions 2018
NUTS1 NUTS Level 1 2015; 2018
NUTS2 NUTS Level 2 2015; 2018
NUTS3 NUTS Level 3 2015; 2018
OA Output Area 2001; 2011
GOR Regions 2018; 2019; 2020; 2021
WM Westminster Parliamentary Constituencies 2018; 2019; 2020; 2021

Basic Usage

library(ukgeog)

# Read in simple feature of the countries that make up the UK 
sf <- read_sf("NAT", year = 2021)

Creating UK Local Authority lookups (2011-2021)

  • across_yr_lookup creates lookups across time to account for boundary changes
  • within_yr_lookup creates within year lookups between LAD’s and UTLA’s

Other functions

  • convert_lnglat converts Eastings/Northings to Latitude/Longitude

Credits

Original shapefiles are created by the Office for National Statistics (ONS) and are available from the Open Geography Portal.