Skip to content
Snippets Groups Projects
Commit feb8e021 authored by Tom Rushby's avatar Tom Rushby
Browse files

Add writing out of simple features (sf) data.

parent 38fa9d5b
Branches
Tags
1 merge request!6Update to include Rushmoor local authority area in Hampshire (previously missing)
...@@ -25,6 +25,8 @@ always_allow_html: yes ...@@ -25,6 +25,8 @@ always_allow_html: yes
--- ---
```{r setup, include=FALSE} ```{r setup, include=FALSE}
# Set to save downloaded geom to shp file
writeFile <- TRUE
# you might need to install these first # you might need to install these first
library(sf) library(sf)
...@@ -35,6 +37,11 @@ library(dplyr) ...@@ -35,6 +37,11 @@ library(dplyr)
library(knitr) library(knitr)
``` ```
```{r}
source("env.R")
```
# Introduction # 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). 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) %>% ...@@ -145,3 +152,14 @@ leaflet(sf_data) %>%
bringToFront = TRUE)) 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"))
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment