-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_load.R
35 lines (21 loc) · 888 Bytes
/
01_load.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Script to load datasets and trim to AOI ---------------------------------
library(sf)
library(bcdata)
library(dplyr)
library(bcmaps)
library(mapview)
## Create out directory ----------------------------------------------------
out_dir <- file.path("out")
dir.create(out_dir)
# Dataset with route on it
route <- st_read(dsn="data/bonnington-tracks.gpkg") |>
transform_bc_albers() |> #transform to crs 3005
rename_all(tolower) |>
st_make_valid() |> #looking for valid geometry
filter(name != "BT-Escape") # focus on main route
# Creating a buffer around the route - setting AOI
route_buffer <- st_buffer(route, 1)
## Trimming DEM to AOI -----------------------------------------------------
bc_dem <- cded(aoi=route_buffer)
## Save outputs ------------------------------------------------------------
saveRDS(c(bc_dem, route_buffer), file='out/cropped-files.RDS')