-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding remaining files for new dataset: Unique Property Reference Num…
…bers (UPRN) in Trafford, derived from Ordnance Survey OS Open UPRN. Due to filesizes being large, commits are split to allow uploading to GitHub.
- Loading branch information
Showing
5 changed files
with
138,140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
<table> | ||
<tr> | ||
<td>Dataset name</td> | ||
<td>Unique Property Reference Numbers in Trafford</td> | ||
</tr> | ||
<tr> | ||
<td>Dataset description</td> | ||
<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> | ||
</tr> | ||
<tr> | ||
<td>Source</td> | ||
<td>Ordnance Survey OS Open UPRN</td> | ||
</tr> | ||
<tr> | ||
<td>Publisher</td> | ||
<td>Ordnance Survey</td> | ||
</tr> | ||
<tr> | ||
<td>Publisher URL</td> | ||
<td><a href="https://osdatahub.os.uk/downloads/open/OpenUPRN" target="_blank">https://osdatahub.os.uk/downloads/open/OpenUPRN</a></td> | ||
</tr> | ||
<tr> | ||
<td>Geography</td> | ||
<td>Points</td> | ||
</tr> | ||
<tr> | ||
<td>Geographic coverage</td> | ||
<td>Trafford</td> | ||
</tr> | ||
<tr> | ||
<td>Temporal coverage</td> | ||
<td>2024-11</td> | ||
</tr> | ||
<tr> | ||
<td>Update frequency</td> | ||
<td>Monthly</td> | ||
</tr> | ||
<tr> | ||
<td>Licence</td> | ||
<td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">Open Government Licence</a></td> | ||
</tr> | ||
<tr> | ||
<td>Attribution</td> | ||
<td>OS Open UPRN provided by <a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td> | ||
</tr> | ||
<tr> | ||
<td>Format</td> | ||
<td>CSV, GeoJSON</td> | ||
</tr> | ||
<tr> | ||
<td>Openness rating</td> | ||
<td>★★★☆☆ Structured data in open format (e.g. CSV)</td> | ||
</tr> | ||
<tr> | ||
<td>Last updated</td> | ||
<td>2024-12-12</td> | ||
</tr> | ||
<tr> | ||
<td>Notes</td> | ||
<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> | ||
</tr> | ||
<tr> | ||
<td>Lab visualisation</td> | ||
<td>View data within the Lab's <a href="https://www.trafforddatalab.io/explore/#dataset=uprn">Explore application</a>.</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
pagetitle: "Unique Property Reference Numbers in Trafford" | ||
lang: "en-GB" | ||
output: | ||
html_document: | ||
css: ../guidance/template/styles.css | ||
self_contained: TRUE | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE) | ||
library(tidyverse) ; library(htmltools) ; library(DT) | ||
df <- read_csv("trafford_unique_property_reference_numbers.csv") %>% | ||
rename_all(. %>% str_to_title() %>% str_replace_all("_", " ")) | ||
``` | ||
<header> | ||
<span id="a11yNav"><a href="#downloads" class="themeBlockDark">Skip to downloads</a></span> | ||
<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> | ||
|
||
<h1>Unique Property Reference Numbers in Trafford</h1> | ||
*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.* | ||
|
||
</header> | ||
|
||
<main> | ||
<h2>Metadata</h2> | ||
|
||
<table id="metadata" class="table table-condensed"> | ||
<thead> | ||
<tr class="header"> | ||
<th>Source</th> | ||
<th>Publisher</th> | ||
<th>Time period</th> | ||
<th>Geography</th> | ||
<th>Licence</th> | ||
<th>Attribution</th> | ||
<th>Last updated</th> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td><a href="https://osdatahub.os.uk/downloads/open/OpenUPRN" target="_blank">Ordnance Survey OS Open UPRN</a></td> | ||
<td><a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td> | ||
<td>Monthly</td> | ||
<td>Point data</td> | ||
<td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">Open Government Licence</a></td> | ||
<td>OS Open UPRN provided by <a href="https://www.ordnancesurvey.co.uk/" target="_blank">Ordnance Survey</a></td> | ||
<td><time datetime="2024-12-12">2024-12-12</time></td> | ||
</tr> | ||
</table> | ||
|
||
<h2>Preview</h2> | ||
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. | ||
|
||
```{r preview} | ||
datatable(df, | ||
class = 'cell-border stripe', | ||
rownames = FALSE, | ||
extensions = c('Scroller', 'Buttons', 'KeyTable'), | ||
options = list( | ||
keys = TRUE, | ||
search = list(regex = TRUE), | ||
searchHighlight = TRUE, | ||
dom = 'ftB', | ||
buttons = list( | ||
list(extend = "csv", | ||
text = "Download selection")), | ||
deferRender = TRUE, | ||
scrollX = TRUE, | ||
scrollY = 300, | ||
scroller = TRUE, | ||
autoWidth = TRUE, | ||
columnDefs = list( | ||
list(className = 'dt-left', targets = "_all") | ||
))) | ||
``` | ||
<div id="tableFooterTitle">Unique Property Reference Numbers in Trafford</div> | ||
|
||
<h2>Data</h2> | ||
<span id ="downloads">Download the complete dataset using the following links:</span> | ||
|
||
|File name |Format | | ||
|---|---| | ||
|[trafford_unique_property_reference_numbers.csv](trafford_unique_property_reference_numbers.csv) |CSV | | ||
|[trafford_unique_property_reference_numbers.geojson](trafford_unique_property_reference_numbers.geojson) |GeoJSON | | ||
|
||
<h2>Pre-processing</h2> | ||
[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>. | ||
|
||
</main> | ||
|
||
<script> | ||
// Fixes to dynamic elements created by DataTables to improve accessibility | ||
var removeElFn = setInterval(removeElement, 1000); | ||
|
||
function removeElement() { | ||
try { | ||
var el = document.getElementsByClassName("dataTables_scrollBody")[0].childNodes[0]; | ||
el.removeChild(el.childNodes[0]); // Remove unwanted hidden text element from table - causing accessibility alert as it has no label | ||
|
||
el.parentNode.setAttribute('tabindex', '0'); // add attribute allowing keyboard users to access scrollable area | ||
|
||
clearInterval(removeElFn); // cancel any further calls to this function as we have completed all actions | ||
} | ||
catch(e) { | ||
// form element 'el' doesn't exist yet so setInterval will call the function again until it does | ||
} | ||
} | ||
</script> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Unique Property Reference Numbers (UPRN) in Trafford | ||
# Source: https://osdatahub.os.uk/downloads/open/OpenUPRN | ||
# Licence: https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/ | ||
|
||
|
||
# Load required packages --------- | ||
library(tidyverse); library(httr); library(sf); library(lubridate) | ||
|
||
|
||
# Download and extract the data --------- | ||
# The data is available updated monthly, so enter the version in the format YYYYMM (you can check the version from the Source URL above) | ||
data_version <- "202411" | ||
|
||
# The URL shouldn't change from the API | ||
data_url <- "https://api.os.uk/downloads/v1/products/OpenUPRN/downloads?area=GB&format=CSV&redirect" | ||
|
||
download.file(data_url, destfile = paste0("osopenuprn_", data_version, "_csv.zip"), timeout = 5000) | ||
unzip(paste0("osopenuprn_", data_version, "_csv.zip"), exdir = ".", files = paste0("osopenuprn_", data_version, ".csv")) | ||
|
||
# Read in the data for the whole of GB | ||
df_uprn_gb <- read_csv(paste0("osopenuprn_", data_version, ".csv")) | ||
|
||
# Tidy-up removing the files we no longer need | ||
file.remove(paste0("osopenuprn_", data_version, "_csv.zip")) | ||
file.remove(paste0("osopenuprn_", data_version, ".csv")) | ||
|
||
|
||
# Extract just the data that lies within Trafford's boundary --------- | ||
# Load in Trafford's boundary as a spatial object | ||
sf_trafford <- st_read("https://www.trafforddatalab.io/council_open_data/boundaries/local_authority_district.geojson") | ||
|
||
# Convert the UPRN dataset into a spatial file using the LATITUDE and LONGITUDE variables | ||
sf_uprn_gb <- df_uprn_gb %>% | ||
# Make copies of the lat/lon coordinates to use later in the dataset as the originals will become the geometry | ||
mutate(lat = LATITUDE, | ||
lon = LONGITUDE) %>% | ||
st_as_sf(coords = c("LONGITUDE", "LATITUDE"), | ||
crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0") | ||
|
||
# Perform spatial join to extract just those UPRNs within Trafford | ||
sf_uprn_trafford <- st_join(sf_uprn_gb, sf_trafford, join = st_within, left = FALSE) | ||
|
||
|
||
# Tidy the resultant spatial dataset for Trafford, renaming variables for clarity and adding version date --------- | ||
sf_uprn_trafford_tidy <- sf_uprn_trafford %>% | ||
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))) %>% | ||
rename(uprn = UPRN, | ||
easting = X_COORDINATE, | ||
northing = Y_COORDINATE, | ||
latitude = lat, | ||
longitude = lon) %>% | ||
select(uprn, latitude, longitude, easting, northing, area_code, area_name, version_date, geometry) | ||
|
||
|
||
# Create the output files --------- | ||
# Convert to a non-spatial dataset in order to output as CSV | ||
df_uprn_trafford <- sf_uprn_trafford_tidy %>% | ||
st_set_geometry(value = NULL) | ||
|
||
write_csv(df_uprn_trafford, "trafford_unique_property_reference_numbers.csv") | ||
st_write(sf_uprn_trafford_tidy, "trafford_unique_property_reference_numbers.geojson", driver = "GeoJSON") | ||
|
Oops, something went wrong.