Appendix - UAV Imagery
Since 2020, orthoimagery and elevation model rasters have been generated and stored as Cloud Optimized Geotiffs on a cloud service provider (AWS) with select imagery linked to in the collaborative GIS project. Additionally - a tile service has been set up to facilitate viewing and downloading of individual images, provided in Table 5.11.
# 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
# Driven from the param, not hardcoded. A literal here shadows params$project_region
# and, because this chunk is eval = F, the table it writes to sqlite outlives the
# repo it was written in — that is how the Fraser 2025 report came to publish Peace
# imagery. See NewGraphEnvironment/fish_passage_fraser_2025_reporting#19.
project_uav <- tab_uav |>
dplyr::filter(region == params$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)