UK Districts: simplified UK local authorities
This script creates simplified UK local authorities districts. It is saved with crs = 3857
.
Load packages, read data, and source custom scripts
rm(list = ls())
library(sf)
#> Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0
library(ggplot2)
library(units)
#> udunits system database from /usr/share/xml/udunits
path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_raw <- file.path(path_data, "raw")
path_cleaned <- file.path(path_data, "cleaned")
path_src <- file.path(path_proj, "src")
path_uk <- file.path(path_raw, "boundaries",
"Local_Authority_Districts__December_2017__Boundaries_in_the_UK__WGS84_.shp")
uk <- st_read(path_uk)
#> Reading layer `Local_Authority_Districts__December_2017__Boundaries_in_the_UK__WGS84_' from data source `/home/rstudio/Documents/Projects/land-suitability/data/raw/boundaries/Local_Authority_Districts__December_2017__Boundaries_in_the_UK__WGS84_.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 391 features and 10 fields
#> geometry type: MULTIPOLYGON
#> dimension: XY
#> bbox: xmin: -8.650774 ymin: 49.86537 xmax: 1.761679 ymax: 60.86015
#> CRS: 4326
uk_3857 <- st_transform(uk, crs = 3857)
Simplified UK boundaries per country
uk_simple <- st_simplify(uk_3857)
st_write(uk_simple, file.path(path_cleaned, "uk_districts.gpkg"), delete_dsn = TRUE)
#> Deleting source `/home/rstudio/Documents/Projects/land-suitability/data/cleaned/uk_districts.gpkg' using driver `GPKG'
#> Writing layer `uk_districts' to data source `/home/rstudio/Documents/Projects/land-suitability/data/cleaned/uk_districts.gpkg' using driver `GPKG'
#> Writing 391 features with 10 fields and geometry type Unknown (any).
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 25.955 1.026 26.697