R/get_asset_path.R

Defines functions get_asset_path

Documented in get_asset_path

#' This function gets path from an asset in the JSON file
#'
#' @param jsonobj character. path for json file
#' @param asset character. name of the asset of interest
#' @param dateAcq date. date of acquisition
#'
#' @return asset_path
#' @export

get_asset_path <- function(jsonobj, asset, dateAcq){
  listAssets <- unlist(lapply(lapply(lapply(jsonobj$features,'[[','assets'),
                                     '[[',asset),'[[','href'))
  DatesAcq <- get_date(prodName = basename(listAssets))
  seldate <- which(DatesAcq==dateAcq)
  asset_path <- listAssets[seldate]
  return(asset_path)
}
jbferet/biodivMapR documentation built on April 12, 2025, 1:32 p.m.