## ----include=FALSE------------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4)
helper <- if (file.exists("vignettes/real-example-helpers.R")) {
  "vignettes/real-example-helpers.R"
} else {
  "real-example-helpers.R"
}
source(helper)
real_mode <- bt_real_examples_enabled()

## ----setup, include=FALSE, eval=bt_real_examples_enabled()--------------------
# real <- bt_real_example_setup()
# real_aoi <- real$aoi

## ----all-layers, eval=bt_real_examples_enabled()------------------------------
# all_layers <- bluertopo(
#   real_aoi,
#   layers = "all",
#   coverage = "fill",
#   details = TRUE,
#   progress = FALSE,
#   quiet = TRUE
# )

## ----layer-table, echo=FALSE, eval=bt_real_examples_enabled()-----------------
# layer_table <- data.frame(
#   layer = c("elevation", "uncertainty", "contributor"),
#   `source band` = c(1L, 2L, 3L),
#   meaning = c(
#     "source elevation values",
#     "source vertical uncertainty values",
#     "categorical contributor/source IDs"
#   ),
#   `default resampling rule` = c(
#     "bilinear only when an explicit output grid is requested",
#     "bilinear only when an explicit output grid is requested; values are then resampled",
#     "nearest-neighbor only; never average contributor IDs"
#   ),
#   check.names = FALSE
# )
# 
# bt_display_table(layer_table)

## ----rat-manifest, echo=FALSE, eval=bt_real_examples_enabled()----------------
# rat_manifest <- as.data.frame(all_layers$downloads)
# rat_manifest <- rat_manifest[rat_manifest$asset_type == "rat", , drop = FALSE]
# rat_table <- data.frame(
#   tile_id = rat_manifest$tile_id,
#   source_basename = rat_manifest$source_basename,
#   local_path = bt_short_path(rat_manifest$local_path, keep = 4L),
#   verified = rat_manifest$verified,
#   actual_sha256 = bt_short_sha(rat_manifest$actual_sha256),
#   stringsAsFactors = FALSE
# )
# 
# bt_display_table(rat_table)

## ----rat-lookup, echo=FALSE, eval=bt_real_examples_enabled()------------------
# contributor_lookup <- bt_parse_rat(rat_manifest$local_path)
# bt_display_table(contributor_lookup)

## ----elevation-plot, echo=FALSE, eval=bt_real_examples_enabled(), fig.cap="BlueTopo bathymetry for New York Harbor, displayed with hillshade, contours, and the example-area boundary.", fig.alt="BlueTopo bathymetry for New York Harbor with hillshade, contours, and the example-area boundary."----
# first_grid <- bt_rasters(all_layers$data)[[1L]]
# bt_plot_bathy_map(first_grid[["elevation"]], real_aoi, main = "New York Harbor elevation")

## ----uncertainty-plot, echo=FALSE, eval=bt_real_examples_enabled(), fig.cap="BlueTopo uncertainty for the selected New York Harbor tiles.", fig.alt="BlueTopo uncertainty raster for the selected New York Harbor tiles."----
# terra::plot(first_grid[["uncertainty"]], main = "Uncertainty", col = grDevices::hcl.colors(80, "BluYl"))
# terra::plot(terra::project(real_aoi, terra::crs(first_grid)), add = TRUE, border = "#d00000", lwd = 2)

## ----contributor-plot, echo=FALSE, eval=bt_real_examples_enabled(), fig.cap="Contributor identifiers for the selected New York Harbor tiles.", fig.alt="BlueTopo contributor identifier raster shown with categorical colors."----
# terra::plot(first_grid[["contributor"]], main = "Contributor IDs", col = hcl.colors(12, "Dark 3"))
# terra::plot(terra::project(real_aoi, terra::crs(first_grid)), add = TRUE, border = "#d00000", lwd = 2)

