Want to see the code? Click on the black boxes on the right to show/hide the code.

Believe it or not, UK Road Numbers aren’t just randomly chosen. They’re actually arranged in a precise system that we can see on this map. I’ve taken the first number from Great Britain’s Motorways and A-roads (eg 4 for M4, 3 for A30) colour coding each 25km x 25km square with the ‘average’ of all the numbers.

Hopefully, you’ll see a pattern - for England and Wales there’s a spiral out from London

and up to Scotland there’s a spiral out from Edinburgh

And the linear boundaries between the zones arem you’ve guessed it - roads! The A1 and A2 roughly define the boundary of zone 1, the A2 and A3 the boundary of zone 2 etc.

# Let's load the sf and mapview libraries to process and view geospatial data
library(sf)
library(mapview)
library(raster)
library(terra)

# Let's select all the numbered road segments for M roads (motorways) and A roads.
numberedRoads <- st_read('./data/02/opname_gb.gpkg', quiet = TRUE, query='SELECT geometry, name1 from named_place where local_type = "Numbered Road" and (name1 like "M%" or name1 like "A%")')

# Create a new field, id, containing the first number of the road
numberedRoads$id <- as.numeric(substr(numberedRoads$name1, 2, 2))

# This creates a blank raster, 25km squares covering the extent of the numberedRoads data
rasterTemplate = rast(ext(numberedRoads), resolution = 25000,
                           crs=st_crs(numberedRoads)$wkt, vals=0)


# We'll use the max value of the id field (the first digit in the road number)
# as the value for each raster cell.
roadNumbers = rasterize(subset(numberedRoads), rasterTemplate, field="id", max)


# And finally, display it on a map.
mapviewOptions(basemaps = c("Esri.WorldShadedRelief"),
               layers.control.pos = "topright",
               leafletWidth = "100%",
               legend = TRUE
               )

mapview(roadNumbers, col.regions = rainbow)

Credits

Data: Ordnance Survey Open Places OGL https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/