Skip to content

Commit

Permalink
Merge pull request #51 from humaniverse/add-ltla-2024
Browse files Browse the repository at this point in the history
Add LTLA 2024 boundaries
  • Loading branch information
MikeJohnPage authored Dec 12, 2024
2 parents 512d243 + 54554c6 commit e881d92
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@
#' @source \url{https://geoportal.statistics.gov.uk/}
"boundaries_ltla21"

#' Local Authority Districts (July 2024)
#'
#' A data set containing 2024 Local Authority Districts (LAD) geometries and
#' their associated names and codes. Boundaries are Ultra Generalised (500m) -
#' clipped to the coastline (Mean High Water mark).
#'
#' @format A data frame of class "sf" with 361 rows and 3 variables:
#' \describe{
#' \item{ltla24_name}{LAD name}
#' \item{ltla24_code}{LAD code}
#' \item{geometry}{multipolygon coordinates}
#' ...
#' }
#' @source \url{https://geoportal.statistics.gov.uk/}
"boundaries_ltla24"

#' Middle Layer Super Output Areas (2011)
#'
#' A data set containing 2011 Middle Super Output Area (MSOA) geometries and
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
55 changes: 55 additions & 0 deletions data-raw/boundaries_ltla24.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ---- Load ----
library(tidyverse)
library(sf)
library(lobstr)
library(devtools)

# Load package
load_all(".")

# Set query url
query_url <-
query_urls |>
filter(id == "ltla24") |>
pull(query)

lad <-
read_sf(query_url) |>
st_transform(crs = 4326)

# Select and rename vars
lad <-
lad |>
select(
ltla24_name = LAD24NM,
ltla24_code = LAD24CD,
geometry
)

# Make sure geometries are valid
lad <- st_make_valid(lad)

# Check geometry types are homogenous
if (lad |>
st_geometry_type() |>
unique() |>
length() > 1) {
stop("Incorrect geometry types")
}

if (lad |>
st_geometry_type() |>
unique() != "MULTIPOLYGON") {
stop("Incorrect geometry types")
}

# Check object is below 50Mb GitHub warning limit
if (obj_size(lad) > 50000000) {
stop("File is too large")
}

# Rename
boundaries_ltla24 <- lad

# Save output to data/ folder
usethis::use_data(boundaries_ltla24, overwrite = TRUE)
1 change: 1 addition & 0 deletions data-raw/query-urls.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ query_urls <-
"boundaries", "ltla19", "01.12.19", "OGLv3", "https://opendata.arcgis.com/datasets/3a4fa2ce68f642e399b4de07643eeed3_0.geojson", "https://geoportal.statistics.gov.uk/datasets/local-authority-districts-december-2019-boundaries-uk-buc/explore?location=55.340150%2C-3.316300%2C6.22",
"boundaries", "ltla20", "12.03.21", "OGLv3", "https://opendata.arcgis.com/datasets/69d8b52032024edf87561fb60fe07c85_0.geojson", "https://geoportal.statistics.gov.uk/datasets/ons::local-authority-districts-december-2020-uk-buc-1/explore?location=55.340122%2C-3.316413%2C5.95",
"boundaries", "ltla21", "01.12.21", "OGLv3", "https://opendata.arcgis.com/datasets/ac4ad96a586b4e4bab306dd59eb09401_0.geojson", "https://geoportal.statistics.gov.uk/datasets/local-authority-districts-december-2021-uk-buc/explore?location=57.654858%2C-11.079503%2C13.82",
"boundaries", "ltla24", "02.07.24", "OGLv3", "https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Local_Authority_Districts_May_2024_Boundaries_UK_BUC/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson", "https://geoportal.statistics.gov.uk/datasets/ons::local-authority-districts-may-2024-boundaries-uk-buc-2/about",
"boundaries", "msoa11", "01.12.11", "OGLv3", "https://opendata.arcgis.com/datasets/80223f1d571c405fb2fdf719c7e6da13_0.geojson", "https://geoportal.statistics.gov.uk/datasets/middle-layer-super-output-areas-december-2011-boundaries-super-generalised-clipped-bsc-ew-v3/explore?location=52.846044%2C-2.465779%2C7.21",
"boundaries", "msoa21", "12.07.23", "OGLv3", "https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/MSOA_2021_EW_BSC_V2/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson", "https://geoportal.statistics.gov.uk/datasets/ed5c7b7d733d4fd582281f9bfc9f02a2_0/explore?location=52.800500%2C-2.489483%2C7.84",
"boundaries", "pfa20", "01.12.20", "OGLv3", "https://opendata.arcgis.com/datasets/2a1e3c23f1f24f15808275f52b8ae20d_0.geojson", "https://geoportal.statistics.gov.uk/datasets/police-force-areas-december-2020-ew-buc/explore?location=52.846527%2C-2.452657%2C7.21",
Expand Down
Binary file added data/boundaries_ltla24.rda
Binary file not shown.
27 changes: 27 additions & 0 deletions man/boundaries_ltla24.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e881d92

Please sign in to comment.