#' # 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 into the LSN
obs<- sites_to_lsn(
sites = MF_obs,
edges = edges,
save_local = FALSE,
snap_tolerance = 100,
overwrite = TRUE,
verbose = FALSE
)
# Incorporate the prediction dataset, preds, into the LSN
preds<- sites_to_lsn(sites = MF_preds,
edges = edges,
save_local = FALSE,
snap_tolerance = 1,
overwrite = TRUE,
verbose = FALSE
)
# Calculate the AFVs for the edges using a column representing
# watershed area (h2oAreaKm2) for the downstream node of each edge
# feature.
edges<- afv_edges(
edges=edges,
infl_col = "h2oAreaKm2",
segpi_col = "areaPI",
lsn_path = temp_dir,
afv_col = "afvArea",
overwrite = TRUE,
save_local = FALSE
)
# Calculate AFVs for observed sites (obs) and the prediction
# dataset, preds.
site.list<- afv_sites(
sites = list(obs = obs,
preds = preds),
edges=edges,
afv_col = "afvArea",
save_local = FALSE,
overwrite = TRUE
)
# Get names of sites in site.list
names(site.list)
# Check AFVs stored in new column afvArea to ensure that 0 <= AFV
# <= 1 and that there are no NULL values.
summary(site.list$obs$afvArea)
summary(site.list$preds$afvArea)
Run the code above in your browser using DataLab