Appendix - UAV Imagery

UAV (drone) imagery products generated for the Peace project area since 2020 are stored as Cloud Optimized GeoTIFFs on AWS. Per-image tile-service viewer and direct download links are provided in Table 5.42.

# only needs to be run at the beginning or if we want to update

# Grab the imagery from the stac

# bc bounding box
bcbbox <-  as.numeric(
  sf::st_bbox(bcmaps::bc_bound()) |> sf::st_transform(crs = 4326)
)

# use rstac to query the collection
q <- rstac::stac("https://images.a11s.one/") |>
    rstac::stac_search(
      collections = "imagery-uav-bc-prod",
                      bbox = bcbbox

                     ) |>
  rstac::post_request()

# get deets of the items
r <- q |>
  rstac::items_fetch()
# build the table to display the info
tab_uav <- tibble::tibble(url_download = purrr::map_chr(r$features, ~ purrr::pluck(.x, "assets", "image", "href"))) |>
  dplyr::mutate(stub = stringr::str_replace_all(url_download, "https://imagery-uav-bc.s3.amazonaws.com/", "")) |>
  tidyr::separate(
    col = stub,
    into = c("region", "watershed_group", "year", "item", "rest"),
    sep = "/",
    extra = "drop"
  ) |>
  dplyr::mutate(
    link_view =
                  dplyr::case_when(
                    !tools::file_path_sans_ext(basename(url_download)) %in% c("dsm", "dtm") ~
                      ngr::ngr_str_link_url(
                        url_base = "https://viewer.a11s.one/?cog=",
                        url_resource = url_download,
                        url_resource_path = FALSE,
                        # anchor_text= "URL View"
                        anchor_text= tools::file_path_sans_ext(basename(url_download))),
                    T ~ "-"),
                        link_download = ngr::ngr_str_link_url(url_base = url_download, anchor_text = url_download)
    )|>
  dplyr::select(region, watershed_group, year, item, link_view, link_download)



# grab the imagery for this project area
project_region <- "skeena"

project_uav <- tab_uav |>
  dplyr::filter(region == project_region)

# how many distinct items are there
# length(unique(project_uav$item))

# Burn to sqlite
conn <- readwritesqlite::rws_connect("data/bcfishpass.sqlite")
readwritesqlite::rws_list_tables(conn)
readwritesqlite::rws_drop_table("project_uav", conn = conn)
readwritesqlite::rws_write(project_uav, exists = F, delete = TRUE,
                           conn = conn, x_name = "project_uav")
readwritesqlite::rws_disconnect(conn)
my_caption <- "Drone imagery download and viewer links."

my_tab_caption()
Table 5.42: Drone imagery download and viewer links. NOTE: To view all columns in the table - please click on one of the sort arrows within column headers before scrolling to the right.
project_uav |>
  my_dt_table(cols_freeze_left = 2, escape = FALSE)