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