# Get temporary directory, where the example LSN will be stored
# locally.
temp_dir <- tempdir()
# Build the LSN. When working with your own data, lsn_path will be
# a local folder of your choice rather than a temporary directory.
edges<- lines_to_lsn(
streams = MF_streams,
lsn_path = temp_dir,
snap_tolerance = 1,
check_topology = FALSE,
overwrite = TRUE,
verbose = FALSE
)
# Incorporate observed sites, MF_obs, into LSN
obs<- sites_to_lsn(
sites = MF_obs,
edges = edges,
save_local = FALSE,
snap_tolerance = 100,
overwrite = TRUE,
verbose = FALSE
)
# Incorporate prediction dataset, MF_preds, into LSN
preds<- sites_to_lsn(
sites = MF_preds,
edges = edges,
save_local = FALSE,
snap_tolerance = 1,
overwrite = TRUE,
verbose = FALSE
)
# Calculate upstream distance for edges
edges<- updist_edges(
edges = edges,
lsn_path = temp_dir,
calc_length = TRUE,
length_col = "Length",
overwrite = TRUE,
save_local = FALSE,
verbose = FALSE
)
# Calculate upstream distance for observed sites (obs) and one
# prediction dataset (preds)
site.list<- updist_sites(
sites = list(obs = obs,
preds = preds),
edges = edges,
length_col= "Length",
lsn_path = temp_dir,
save_local = FALSE,
overwrite = TRUE
)
# Summarize the new column upDist in obs
summary(site.list$obs$upDist)
# Summarize the new column upDist in preds
summary(site.list$preds$upDist)
Run the code above in your browser using DataLab