-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_rivers.R
41 lines (29 loc) · 1 KB
/
os_rivers.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
35
36
37
38
39
40
pacman::p_load(tidyverse,
sf,
fs,
glue,
janitor,
tmap,
tmaptools,
ggmap
)
# read and process open rivers data form OS for publishing on LNRS layers in portal
path <- "data/LNRS-portal-layers/03 - GIS Layers for Portal/oprvrs_essh_gb_OS_open_rivers/data"
gpkg_path <- fs::dir_ls(path, glob = "*.gpkg")
st_layers(gpkg_path)
rivers_os <- st_read(gpkg_path, layer = "watercourse_link")
# boundary of weca + NS
lep_buffer_sf <- st_read("../lnrs/data/lep_boundary.geojson") %>%
st_buffer(dist = 1000)
clipped_rivers_sf <- rivers_os %>%
st_intersection(lep_buffer_sf) %>%
select(-name, -id.1) %>%
st_transform(crs = st_crs("WGS84"))
# plot the rivers
clipped_rivers_sf %>% plot()
# export the rivers for portal
clipped_rivers_sf %>%
st_write(glue("{path}/ods-os-open-rivers_{Sys.Date()}_.geojson"),
delete_layer = TRUE,
delete_dsn = TRUE,
append = FALSE)