Skip to content

Commit 0fe8347

Browse files
authored
Merge pull request #56 from humaniverse/boundaries-lrf
Resilience and Preparedness boundaries
2 parents 402cdff + f0d81a0 commit 0fe8347

13 files changed

Lines changed: 320 additions & 4 deletions

R/data.R

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
#' @source \url{https://spatialdata.gov.scot/}
4545
"boundaries_dz11"
4646

47+
#' Emergency Preparedness Groups, Northern Ireland (2004)
48+
#'
49+
#' A data set containing 2004 NI Emergency Preparedness Group geometries and their associated
50+
#' names. Boundaries created by dissolving LGD geometries, from ONS.
51+
#'
52+
#' @format A data frame of class "sf" with 3 rows and 2 variables:
53+
#' \describe{
54+
#' \item{epg04_name}{Emergency Preparedness Greoup name}
55+
#' \item{geometry}{multipolygon coordinates}
56+
#' ...
57+
#' }
58+
#' @source \url{https://geoportal.statistics.gov.uk//}
59+
"boundaries_epg04"
60+
4761
#' Health Boards (2019)
4862
#'
4963
#' A data set containing 2019 NHS Health Board geometries and their associated
@@ -119,6 +133,36 @@
119133
#' @source \url{https://geoportal.statistics.gov.uk/}
120134
"boundaries_lhb22"
121135

136+
#' England and Wales Local Resilience Forums (2020)
137+
#'
138+
#' A data set containing 2020 Local Resilience Forum geometries for England and Wales and their
139+
#' associated names and codes.
140+
#'
141+
#' @format A data frame of class "sf" with 42 rows and 3 variables:
142+
#' \describe{
143+
#' \item{lrf20_name}{Local Resilience Forum name}
144+
#' \item{lrf20_code}{Local Resilience Forum code}
145+
#' \item{geometry}{multipolygon coordinates}
146+
#' ...
147+
#' }
148+
#' @source \url{https://geoportal.statistics.gov.uk/}
149+
"boundaries_lrf20"
150+
151+
#' Scotland Local Resilience Partnerships (2019)
152+
#'
153+
#' A data set containing 2019 Local Resilience Partnership geometries for Scotland and their
154+
#' associated names and codes.
155+
#'
156+
#' @format A data frame of class "sf" with 12 rows and 3 variables:
157+
#' \describe{
158+
#' \item{lrp19_name}{Local Resilience Partnership name}
159+
#' \item{lrp19_code}{Local Resilience Partnership code}
160+
#' \item{geometry}{multipolygon coordinates}
161+
#' ...
162+
#' }
163+
#' @source \url{https://data.gov.uk/}
164+
"boundaries_lrp19"
165+
122166
#' Lower Layer Super Output Areas (2011)
123167
#'
124168
#' A data set containing 2011 Lower Super Output Area (LSOA) geometries and
@@ -1422,11 +1466,11 @@
14221466
#'
14231467
#' A data set containing a lookup between SOA and LGD in Northern Ireland.
14241468
#'
1425-
#' @format A data frame of class "tbl" with 13,865 rows and 2 variables:
1469+
#' @format A data frame of class "tbl" with 890 rows and 3 variables:
14261470
#' \describe{
14271471
#' \item{soa01_code}{Super Output Area 2001 code}
14281472
#' \item{lgd14_code}{Local Government District 2014 code}
1429-
#' \item{ldg14_name}{Local Government District 2014 name}
1473+
#' \item{lgd14_name}{Local Government District 2014 name}
14301474
#' ...
14311475
#' }
14321476
#' @source \url{https://www.nisra.gov.uk/publications/geography-lookup-tables}

R/sysdata.rda

269 Bytes
Binary file not shown.

data-raw/boundaries_epg04.R

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# ---- Load ----
2+
library(tidyverse)
3+
library(sf)
4+
library(lobstr)
5+
library(devtools)
6+
7+
# Load package
8+
load_all(".")
9+
10+
lgd <-
11+
boundaries_ltla24 |>
12+
filter(str_starts(ltla24_code, "N"))
13+
14+
# Create LGD - EPG lookup
15+
# Source: P.22 for map https://www.executiveoffice-ni.gov.uk/sites/default/files/publications/ofmdfm_dev/The%20Northern%20Ireland%20Civil%20Contingencies%20Framework%20%28Revised%202023%29.pdf
16+
lookup <- tibble(
17+
ltla24_code = c(
18+
"N09000001", "N09000002", "N09000003", "N09000004", "N09000005",
19+
"N09000006", "N09000007", "N09000008", "N09000009", "N09000010",
20+
"N09000011"
21+
),
22+
epg04_name = c(
23+
"North", "South", "Belfast", "North", "North", "South", "South",
24+
"North", "South", "South", "South"
25+
)
26+
)
27+
28+
# Dissolve LGDs to create EPG groupings
29+
epg <- lgd |>
30+
left_join(lookup) |>
31+
group_by(epg04_name) |>
32+
summarise(geometry = st_union(geometry))
33+
34+
# Make sure geometries are valid
35+
epg <- st_make_valid(epg)
36+
37+
# Check geometry types are homogenous
38+
if (epg |>
39+
st_geometry_type() |>
40+
unique() |>
41+
length() > 1) {
42+
stop("Incorrect geometry types")
43+
}
44+
45+
if (epg |>
46+
st_geometry_type() |>
47+
unique() != "MULTIPOLYGON") {
48+
stop("Incorrect geometry types")
49+
}
50+
51+
# Check object is below 50Mb GitHub warning limit
52+
if (obj_size(epg) > 50000000) {
53+
stop("File is too large")
54+
}
55+
56+
# Rename
57+
boundaries_epg04 <- epg
58+
59+
# Save output to data/ folder
60+
usethis::use_data(boundaries_epg04, overwrite = TRUE)

data-raw/boundaries_lrf20.R

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ---- Load ----
2+
library(tidyverse)
3+
library(sf)
4+
library(lobstr)
5+
library(devtools)
6+
7+
# Load package
8+
load_all(".")
9+
10+
# Set query url
11+
query_url <-
12+
query_urls |>
13+
filter(id == "lrf20") |>
14+
pull(query)
15+
16+
lrf <-
17+
read_sf(query_url) |>
18+
st_transform(crs = 4326)
19+
20+
# Select and rename vars
21+
lrf <-
22+
lrf |>
23+
select(
24+
lrf20_name = LRF20NM,
25+
lrf20_code = LRF20CD,
26+
geometry
27+
)
28+
29+
# Make sure geometries are valid
30+
lrf <- st_make_valid(lrf)
31+
32+
# Check geometry types are homogenous
33+
if (lrf |>
34+
st_geometry_type() |>
35+
unique() |>
36+
length() > 1) {
37+
stop("Incorrect geometry types")
38+
}
39+
40+
if (lrf |>
41+
st_geometry_type() |>
42+
unique() != "MULTIPOLYGON") {
43+
stop("Incorrect geometry types")
44+
}
45+
46+
# Check object is below 50Mb GitHub warning limit
47+
if (obj_size(lrf) > 50000000) {
48+
stop("File is too large")
49+
}
50+
51+
# Rename
52+
boundaries_lrf20 <- lrf
53+
54+
# Save output to data/ folder
55+
usethis::use_data(boundaries_lrf20, overwrite = TRUE)

data-raw/boundaries_lrp19.R

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ---- Load ----
2+
library(tidyverse)
3+
library(sf)
4+
library(lobstr)
5+
library(devtools)
6+
library(httr)
7+
8+
# Load package
9+
load_all(".")
10+
11+
# Set query url
12+
query_url <-
13+
query_urls |>
14+
filter(id == "lrp19") |>
15+
pull(query)
16+
17+
# GET and unzip shapefiles
18+
GET(
19+
query_url,
20+
write_disk(
21+
zip_folder <- tempfile(fileext = ".zip")
22+
)
23+
)
24+
25+
unzip(zip_folder, exdir = tempdir())
26+
27+
shp <- file.path(tempdir(), "SG_LocalResiliencePartnerships_2019.shp")
28+
29+
lrp <-
30+
read_sf(shp) |>
31+
st_transform(crs = 4326)
32+
33+
# Select and rename vars
34+
lrp <-
35+
lrp |>
36+
select(
37+
lrp19_name = LRPCode,
38+
lrp19_code = LRPName,
39+
geometry
40+
)
41+
42+
# Make sure geometries are valid
43+
lrp <- st_make_valid(lrp)
44+
45+
# Check geometry types are homogenous
46+
if (lrp |>
47+
st_geometry_type() |>
48+
unique() |>
49+
length() > 1) {
50+
stop("Incorrect geometry types")
51+
}
52+
53+
if (lrp |>
54+
st_geometry_type() |>
55+
unique() != "MULTIPOLYGON") {
56+
stop("Incorrect geometry types")
57+
}
58+
59+
# Check object is below 50Mb GitHub warning limit
60+
if (obj_size(lrp) > 50000000) {
61+
stop("File is too large")
62+
}
63+
64+
# Rename
65+
boundaries_lrp19 <- lrp
66+
67+
# Save output to data/ folder
68+
usethis::use_data(boundaries_lrp19, overwrite = TRUE)

data-raw/query-urls.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ query_urls <-
123123
"https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Regions_December_2021_EN_BFC/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json",
124124
"https://geoportal.statistics.gov.uk/datasets/ons::regions-december-2021-en-bfc/about",
125125
"boundaries",
126+
"lrf20",
127+
"11.08.25",
128+
"OGLv3",
129+
"https://stg-arcgisazurecdataprod1.az.arcgis.com/exportfiles-1559-19925/Local_Resilience_Forums_December_2020_Boundaries_EW_BUC_V2_-5553395016356054869.geojson?sv=2018-03-28&sr=b&sig=VJSdI8HjxvJlIoJnyeIAuI8uTc2mhFHZPoBFEdC44L0%3D&se=2025-10-06T15%3A24%3A41Z&sp=r",
130+
"https://geoportal.statistics.gov.uk/datasets/611c9a6e6baf424e9e29932c53e5851b_0/explore",
131+
"boundaries",
132+
"lrp19",
133+
"27.02.25",
134+
"OGLv3",
135+
"https://maps.gov.scot/ATOM/shapefiles/SG_LocalResiliencePartnerships_2019.zip",
136+
"https://www.data.gov.uk/dataset/fc3f821f-65ab-4d09-a7f0-48ffa1a6d141/local-resilience-partnerships",
137+
"boundaries",
126138
"sdz21",
127139
"21.02.23",
128140
"OGLv3",

data/boundaries_epg04.rda

9.45 KB
Binary file not shown.

data/boundaries_lrf20.rda

96.5 KB
Binary file not shown.

data/boundaries_lrp19.rda

16.7 MB
Binary file not shown.

man/boundaries_epg04.Rd

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)