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.
# install.packages("remotes") remotes::install_github("l-hodge/ukgeog")
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:
library(ukgeog) library(dplyr) library(stringr)
available_sf() %>% dplyr::group_by(geog, geog_short) %>% dplyr::arrange(year) %>% dplyr::summarize(year = stringr::str_c(year, collapse = "; "), .groups = "drop") %>% dplyr::select("'geog'" = geog_short, "Geography" = geog, "Year" = year) %>% knitr::kable()
library(ukgeog) # Read in simple feature of the countries that make up the UK sf <- read_sf("NAT", year = 2021)
across_yr_lookup
creates lookups across time to account for boundary changeswithin_yr_lookup
creates within year lookups between LAD's and UTLA'sconvert_lnglat
converts Eastings/Northings to Latitude/Longitudeukgeog
Original shapefiles are created by the Office for National Statistics (ONS) and are available from the Open Geography Portal.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.