diff --git a/ONS-open-geography.Rmd b/ONS-open-geography.Rmd index d05cd9e7f100581f050768ed11314fb911aa75e5..c9069360e384d047d35dc9bc125847281acafc57 100644 --- a/ONS-open-geography.Rmd +++ b/ONS-open-geography.Rmd @@ -25,6 +25,8 @@ always_allow_html: yes --- ```{r setup, include=FALSE} +# Set to save downloaded geom to shp file +writeFile <- TRUE # you might need to install these first library(sf) @@ -35,6 +37,11 @@ library(dplyr) library(knitr) ``` +```{r} +source("env.R") +``` + + # Introduction This script provides an example of downloading and importing administrative boundaries from the Office for National Statistics Open Geography portal into RStudio and plotting on a map. It is based upon a useful example by [Trafford Data Lab](https://medium.com/@traffordDataLab/pushing-the-boundaries-with-the-open-geography-portal-api-4d70637bddc3). @@ -145,3 +152,14 @@ leaflet(sf_data) %>% bringToFront = TRUE)) ``` +# Write out shape file + +```{r} +# Set output directory +outDir <- paste0(dPath, "_R_output/") +# Write simple features to file see https://r-spatial.github.io/sf/articles/sf2.html#using-st_write +if(writeFile) { + st_write(sf_data, paste0(outDir,"LA_solent_2020.shp")) +} +``` +