I’ve just added some more data to the {blimey}
package:
- postal codes and
- postbox locations.
Data Sources
The postal code data was acquired from gov.uk as a collection of CSV files. The data were read and consolidated into a single data frame. The coordinates were transformed from CRS 27700 (British National Grid) to CRS 4326 (World Geodetic System).
The postbox locations were retrieved from https://postboxes.dracos.co.uk/, an awesome interactive map created by Matthew Somerville using data from the Royal Mail. The data were lightly cleaned (there’s still some work to be done though).
Load the Package
If you haven’t installed the package, then grab it from GitHub.
devtools::install_github("datawookie/blimey")
Load the package.
library(blimey)
Postal Codes
First let’s look at the postal code data.
postal
# A tibble: 1,728,243 × 4
postcode lat lon country_iso
<chr> <dbl> <dbl> <chr>
1 AB10 1AB 57.1 -2.10 SCT
2 AB10 1AF 57.1 -2.10 SCT
3 AB10 1AG 57.1 -2.10 SCT
4 AB10 1AH 57.1 -2.10 SCT
5 AB10 1AL 57.2 -2.10 SCT
6 AB10 1AN 57.1 -2.09 SCT
7 AB10 1AP 57.1 -2.10 SCT
8 AB10 1AQ 57.1 -2.09 SCT
9 AB10 1AR 57.1 -2.10 SCT
10 AB10 1AS 57.1 -2.10 SCT
# … with 1,728,233 more rows
# ℹ Use `print(n = ...)` to see more rows
The data covers England, Scotland and Wales.
postal %>% pull(country_iso) %>% unique() %>% sort()
[1] "ENG" "SCT" "WLS"
It would be really useful to have the polygons for the postal code boundaries. However, for the moment there’s only a single coordinate. This should still be useful for a variety of applications. For example, smashing together the schools
and postal
data allows us to plot the locations of schools broken down by their Ofsted rating.
Postboxes
Now let’s take a look at postboxes
.
nrow(postboxes)
[1] 115905
There are a lot of postboxes in the United Kingdom! We’ll narrow our attention to Shoreham-by-Sea, a little seaside town in West Sussex.
# A tibble: 33 × 5
postbox_code name lat lon last_collection
<chr> <chr> <dbl> <dbl> <chr>
1 BN43 1533 The Burrells 50.8 -0.257 Mo-Fr 09:00; Sa 07:00
2 BN43 1534 Shingle Road 50.8 -0.265 Mo-Fr 09:00; Sa 07:00
3 BN43 1532 Winterton Way 50.8 -0.261 Mo-Fr 09:00; Sa 07:00
4 BN43 1535 East Beach Post Office 50.8 -0.272 Mo-Fr 17:00; Sa 12:15
5 BN43 1536 Beach Green 50.8 -0.281 Mo-Fr 09:00; Sa 07:00
6 BN43 1511 Kingston Lane 50.8 -0.245 Mo-Fr 09:00, Sa 07:00
7 BN43 1529 Dolphin Road 50.8 -0.262 Mo-Fr 18:15; Sa 12:30
8 BN43 1543 Riverside Business Box 50.8 -0.268 Mo-Fr 18:30
9 BN43 1540 Surrey Street 50.8 -0.269 Mo-Fr 18:00; Sa 11:45
10 BN43 1512 St Julians 50.8 -0.249 Mo-Fr 17:00; Sa 11:45
# … with 23 more rows
# ℹ Use `print(n = ...)` to see more rows
There are two additional fields, postal_code
and address
. Using these data we can immediately plot out the locations of the postboxes.
Fun Challenge
A fun challenge would be to transform the last_collection
field in the postboxes
data into wide format, with one column per day of week.