Skip to content

Commit 19e730d

Browse files
committed
Adding remaining files for new dataset: Unique Property Reference Numbers (UPRN) in Trafford, derived from Ordnance Survey OS Open UPRN. Due to filesizes being large, commits are split to allow uploading to GitHub.
1 parent a4535ae commit 19e730d

5 files changed

Lines changed: 138140 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
<table>
3+
<tr>
4+
<td>Dataset name</td>
5+
<td>Unique Property Reference Numbers in Trafford</td>
6+
</tr>
7+
<tr>
8+
<td>Dataset description</td>
9+
<td>An open dataset containing all the Unique Property Reference Numbers (UPRNs) within Trafford found in AddressBase Premium, with their respective geometries in British National Grid and Latitude, Longitude.</td>
10+
</tr>
11+
<tr>
12+
<td>Source</td>
13+
<td>Ordnance Survey OS Open UPRN</td>
14+
</tr>
15+
<tr>
16+
<td>Publisher</td>
17+
<td>Ordnance Survey</td>
18+
</tr>
19+
<tr>
20+
<td>Publisher URL</td>
21+
<td><a href="https://osdatahub.os.uk/downloads/open/OpenUPRN" target="_blank">https://osdatahub.os.uk/downloads/open/OpenUPRN</a></td>
22+
</tr>
23+
<tr>
24+
<td>Geography</td>
25+
<td>Points</td>
26+
</tr>
27+
<tr>
28+
<td>Geographic coverage</td>
29+
<td>Trafford</td>
30+
</tr>
31+
<tr>
32+
<td>Temporal coverage</td>
33+
<td>2024-11</td>
34+
</tr>
35+
<tr>
36+
<td>Update frequency</td>
37+
<td>Monthly</td>
38+
</tr>
39+
<tr>
40+
<td>Licence</td>
41+
<td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">Open Government Licence</a></td>
42+
</tr>
43+
<tr>
44+
<td>Attribution</td>
45+
<td>OS Open UPRN provided by <a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td>
46+
</tr>
47+
<tr>
48+
<td>Format</td>
49+
<td>CSV, GeoJSON</td>
50+
</tr>
51+
<tr>
52+
<td>Openness rating</td>
53+
<td>&#9733&#9733&#9733&#9734&#9734&nbsp; Structured data in open format (e.g. CSV)</td>
54+
</tr>
55+
<tr>
56+
<td>Last updated</td>
57+
<td>2024-12-12</td>
58+
</tr>
59+
<tr>
60+
<td>Notes</td>
61+
<td>The Unique Property Reference Number (UPRN) is a unique 12 digit number assigned to every unit of land and property recorded by local government. The UPRN uniquely and definitively identifies every addressable location in the country.</td>
62+
</tr>
63+
<tr>
64+
<td>Lab visualisation</td>
65+
<td>View data within the Lab's <a href="https://www.trafforddatalab.io/explore/#dataset=uprn">Explore application</a>.</td>
66+
</tr>
67+
</table>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
pagetitle: "Unique Property Reference Numbers in Trafford"
3+
lang: "en-GB"
4+
output:
5+
html_document:
6+
css: ../guidance/template/styles.css
7+
self_contained: TRUE
8+
---
9+
10+
```{r setup, include=FALSE}
11+
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
12+
library(tidyverse) ; library(htmltools) ; library(DT)
13+
14+
df <- read_csv("trafford_unique_property_reference_numbers.csv") %>%
15+
rename_all(. %>% str_to_title() %>% str_replace_all("_", " "))
16+
```
17+
<header>
18+
<span id="a11yNav"><a href="#downloads" class="themeBlockDark">Skip to downloads</a></span>
19+
<a href="https://www.trafforddatalab.io/data.html"><img src="https://www.trafforddatalab.io/assets/logo/trafforddatalab_logo.svg" alt="Trafford Data Lab" aria-label="Return to Trafford Data Lab data page" width="100" class="traffordDataLabLogo"/></a>
20+
21+
<h1>Unique Property Reference Numbers in Trafford</h1>
22+
*The Unique Property Reference Number (UPRN) is a unique 12 digit number assigned to every unit of land and property recorded by local government. The UPRN uniquely and definitively identifies every addressable location in the country.*
23+
24+
</header>
25+
26+
<main>
27+
<h2>Metadata</h2>
28+
29+
<table id="metadata" class="table table-condensed">
30+
<thead>
31+
<tr class="header">
32+
<th>Source</th>
33+
<th>Publisher</th>
34+
<th>Time period</th>
35+
<th>Geography</th>
36+
<th>Licence</th>
37+
<th>Attribution</th>
38+
<th>Last updated</th>
39+
</tr>
40+
</thead>
41+
<tr>
42+
<td><a href="https://osdatahub.os.uk/downloads/open/OpenUPRN" target="_blank">Ordnance Survey OS Open UPRN</a></td>
43+
<td><a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td>
44+
<td>Monthly</td>
45+
<td>Point data</td>
46+
<td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">Open Government Licence</a></td>
47+
<td>OS Open UPRN provided by <a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td>
48+
<td><time datetime="2024-12-12">2024-12-12</time></td>
49+
</tr>
50+
</table>
51+
52+
<h2>Preview</h2>
53+
Sort, filter and export a selection of the data using the table. An <a href="https://www.trafforddatalab.io/explore/#dataset=uprn" target="_blank">interactive map</a> is also available.
54+
55+
```{r preview}
56+
datatable(df,
57+
class = 'cell-border stripe',
58+
rownames = FALSE,
59+
extensions = c('Scroller', 'Buttons', 'KeyTable'),
60+
options = list(
61+
keys = TRUE,
62+
search = list(regex = TRUE),
63+
searchHighlight = TRUE,
64+
dom = 'ftB',
65+
buttons = list(
66+
list(extend = "csv",
67+
text = "Download selection")),
68+
deferRender = TRUE,
69+
scrollX = TRUE,
70+
scrollY = 300,
71+
scroller = TRUE,
72+
autoWidth = TRUE,
73+
columnDefs = list(
74+
list(className = 'dt-left', targets = "_all")
75+
)))
76+
```
77+
<div id="tableFooterTitle">Unique Property Reference Numbers in Trafford</div>
78+
79+
<h2>Data</h2>
80+
<span id ="downloads">Download the complete dataset using the following links:</span>
81+
82+
|File name |Format |
83+
|---|---|
84+
|[trafford_unique_property_reference_numbers.csv](trafford_unique_property_reference_numbers.csv) |CSV |
85+
|[trafford_unique_property_reference_numbers.geojson](trafford_unique_property_reference_numbers.geojson) |GeoJSON |
86+
87+
<h2>Pre-processing</h2>
88+
[The R script used to process the data](pre-processing.R) can be adapted to other areas. For information about R visit the <a href="https://cran.r-project.org" target="_blank">CRAN website</a>.
89+
90+
</main>
91+
92+
<script>
93+
// Fixes to dynamic elements created by DataTables to improve accessibility
94+
var removeElFn = setInterval(removeElement, 1000);
95+
96+
function removeElement() {
97+
try {
98+
var el = document.getElementsByClassName("dataTables_scrollBody")[0].childNodes[0];
99+
el.removeChild(el.childNodes[0]); // Remove unwanted hidden text element from table - causing accessibility alert as it has no label
100+
101+
el.parentNode.setAttribute('tabindex', '0'); // add attribute allowing keyboard users to access scrollable area
102+
103+
clearInterval(removeElFn); // cancel any further calls to this function as we have completed all actions
104+
}
105+
catch(e) {
106+
// form element 'el' doesn't exist yet so setInterval will call the function again until it does
107+
}
108+
}
109+
</script>

unique_property_reference_numbers/index.html

Lines changed: 3448 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Unique Property Reference Numbers (UPRN) in Trafford
2+
# Source: https://osdatahub.os.uk/downloads/open/OpenUPRN
3+
# Licence: https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
4+
5+
6+
# Load required packages ---------
7+
library(tidyverse); library(httr); library(sf); library(lubridate)
8+
9+
10+
# Download and extract the data ---------
11+
# The data is available updated monthly, so enter the version in the format YYYYMM (you can check the version from the Source URL above)
12+
data_version <- "202411"
13+
14+
# The URL shouldn't change from the API
15+
data_url <- "https://api.os.uk/downloads/v1/products/OpenUPRN/downloads?area=GB&format=CSV&redirect"
16+
17+
download.file(data_url, destfile = paste0("osopenuprn_", data_version, "_csv.zip"), timeout = 5000)
18+
unzip(paste0("osopenuprn_", data_version, "_csv.zip"), exdir = ".", files = paste0("osopenuprn_", data_version, ".csv"))
19+
20+
# Read in the data for the whole of GB
21+
df_uprn_gb <- read_csv(paste0("osopenuprn_", data_version, ".csv"))
22+
23+
# Tidy-up removing the files we no longer need
24+
file.remove(paste0("osopenuprn_", data_version, "_csv.zip"))
25+
file.remove(paste0("osopenuprn_", data_version, ".csv"))
26+
27+
28+
# Extract just the data that lies within Trafford's boundary ---------
29+
# Load in Trafford's boundary as a spatial object
30+
sf_trafford <- st_read("https://www.trafforddatalab.io/council_open_data/boundaries/local_authority_district.geojson")
31+
32+
# Convert the UPRN dataset into a spatial file using the LATITUDE and LONGITUDE variables
33+
sf_uprn_gb <- df_uprn_gb %>%
34+
# Make copies of the lat/lon coordinates to use later in the dataset as the originals will become the geometry
35+
mutate(lat = LATITUDE,
36+
lon = LONGITUDE) %>%
37+
st_as_sf(coords = c("LONGITUDE", "LATITUDE"),
38+
crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
39+
40+
# Perform spatial join to extract just those UPRNs within Trafford
41+
sf_uprn_trafford <- st_join(sf_uprn_gb, sf_trafford, join = st_within, left = FALSE)
42+
43+
44+
# Tidy the resultant spatial dataset for Trafford, renaming variables for clarity and adding version date ---------
45+
sf_uprn_trafford_tidy <- sf_uprn_trafford %>%
46+
mutate(version_date = paste(month(ymd(paste0(substring(data_version, 1, 4), "-", substring(data_version, 5, 6), "-01")), label = TRUE, abbr = FALSE), substring(data_version, 1, 4))) %>%
47+
rename(uprn = UPRN,
48+
easting = X_COORDINATE,
49+
northing = Y_COORDINATE,
50+
latitude = lat,
51+
longitude = lon) %>%
52+
select(uprn, latitude, longitude, easting, northing, area_code, area_name, version_date, geometry)
53+
54+
55+
# Create the output files ---------
56+
# Convert to a non-spatial dataset in order to output as CSV
57+
df_uprn_trafford <- sf_uprn_trafford_tidy %>%
58+
st_set_geometry(value = NULL)
59+
60+
write_csv(df_uprn_trafford, "trafford_unique_property_reference_numbers.csv")
61+
st_write(sf_uprn_trafford_tidy, "trafford_unique_property_reference_numbers.geojson", driver = "GeoJSON")
62+

0 commit comments

Comments
 (0)