## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4) ## ----setup, message = FALSE--------------------------------------------------- library(blueterra) library(terra) ## ----data--------------------------------------------------------------------- bathy <- read_bathy(blueterra_example("hitw")) rectangles <- terra::vect(blueterra_example("sampling_rectangles")) hitw_rect <- rectangles[rectangles$site_id == "hitw", ] prepared <- prepare_bathy( bathy, depth_range = c(-220, -25), smooth = TRUE ) estimate_surface_orientation(prepared, hitw_rect) ## ----automatic---------------------------------------------------------------- transects <- make_transects( hitw_rect, spacing = 75, bathy = prepared ) transects[, c("transect_id", "angle_deg", "angle_source", "mean_aspect_deg")] ## ----automatic-map, eval=requireNamespace("ggplot2", quietly = TRUE), fig.alt="Automatically oriented transects over hillshaded bathymetry."---- plot_transects( prepared, transects, color_by = "transect_id", show_legend = FALSE, contour_interval = 25, title = "Terrain-Oriented Transects", subtitle = "Line angle estimated from local surface aspect" ) ## ----manual------------------------------------------------------------------- manual_transects <- make_transects( hitw_rect, spacing = 75, angle = 45 ) manual_transects[, c("transect_id", "angle_deg", "angle_source")] ## ----sample------------------------------------------------------------------- samples <- sample_transects(transects, prepared, n = 12) sections <- extract_cross_sections(transects, prepared, n = 12) head(samples[, c("transect_id", "distance", "x", "y", "bathy_m")]) summarize_cross_sections(samples, value_col = "bathy_m") identical(names(samples), names(sections)) ## ----cross-section-plot, eval=requireNamespace("ggplot2", quietly = TRUE), fig.alt="Bathymetric cross-sections with bathy_m on the y-axis."---- plot_cross_sections( samples, value_col = "bathy_m", show_legend = TRUE, mean_profile = TRUE, mean_profile_na_rm = TRUE, normalize_distance = FALSE, profile_direction = "top_to_bottom", title = "Bathymetric Cross-Sections", subtitle = "Profiles read from shallow to deep terrain" ) ## ----profile, eval=requireNamespace("ggplot2", quietly = TRUE), fig.alt="Bathymetric profile along a single transect."---- one <- samples[samples$transect_id == samples$transect_id[1], ] plot_depth_profile( one, value_col = "bathy_m", profile_direction = "top_to_bottom", title = "Bathymetry Along One Transect" ) ## ----slope-profile, eval=requireNamespace("ggplot2", quietly = TRUE), fig.alt="Slope profile along one transect."---- metrics <- derive_terrain(prepared, metrics = c("slope", "tri", "bpi")) metric_samples <- sample_transects( transects, c(prepared, metrics[["slope_deg"]]), n = 25 ) metric_one <- metric_samples[metric_samples$transect_id == metric_samples$transect_id[1], ] plot_depth_profile( metric_one, depth_col = "bathy_m", value_col = "slope_deg", profile_direction = "top_to_bottom", title = "Slope Along Depth" )