## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4)

## ----setup, message = FALSE---------------------------------------------------
library(blueterra)
library(terra)

## ----path---------------------------------------------------------------------
path <- blueterra_example("hoyo")
hoyo <- read_bathy(path)
same_hoyo <- as_bathy(hoyo)

class(path)
class(hoyo)
class(same_hoyo)
bathy_info(hoyo)

## ----vector-------------------------------------------------------------------
rectangles <- terra::vect(blueterra_example("sampling_rectangles"))
rectangles[, c("site_id", "site_name", "feature_type")]

hoyo_rect <- rectangles[rectangles$site_id == "hoyo", ]
masked <- mask_bathy(hoyo, hoyo_rect)
class(masked)

## ----crs----------------------------------------------------------------------
check_bathy_crs(hoyo)
terra::crs(hoyo, proj = TRUE)
terra::res(hoyo)

## ----project------------------------------------------------------------------
coarse_template <- terra::aggregate(hoyo, fact = 2)
projected <- project_bathy(coarse_template, terra::crs(hoyo))
class(projected)

## ----sign---------------------------------------------------------------------
check_bathy_units(hoyo, units = "m", positive_depth = FALSE)
range(terra::values(hoyo), na.rm = TRUE)

positive_depth <- set_depth_positive(hoyo)
range(terra::values(positive_depth), na.rm = TRUE)

## ----bands--------------------------------------------------------------------
summarize_depth_bands(
  hoyo,
  breaks = c(-260, -180, -120, -60, -20)
)

## ----map, eval=requireNamespace("ggplot2", quietly = TRUE), fig.alt="El Hoyo bathymetry with hillshade, contours, and sampling rectangle."----
plot_bathy(
  hoyo,
  contours = TRUE,
  contour_interval = 25,
  vectors = hoyo_rect,
  title = "El Hoyo Bathymetry",
  subtitle = "Hillshade, contours, and sampling rectangle"
)

