R/wdpa_latest_version.R

Defines functions wdpa_latest_version

Documented in wdpa_latest_version

#' @include internal.R wdpa_url.R
NULL

#' Query latest version
#'
#' Find the latest version of the combined
#' World Database on Protected Areas
#' (WDPA) and World Database on Other Effective Area-Based Conservation Measures
#' (WDOECM) dataset.
#' This is a character identifier representing the month and year (e.g.
#' `Sep2020`) the data were released.
#'
#' @details The version number is determined using a web address where the
#'   global dataset is available. For specific details, please refer to
#'   the source code for this function.
#'
#' @return `character` version of the dataset.
#'
#' @examples
#' \dontrun{
#' # find the latest version
#' wdpa_latest_version()
#' }
#'
#' @export
wdpa_latest_version <- function() {
  assertthat::assert_that(is_online())
  download_url <- "http://wcmc.io/wdpa_current_release"
  file_name <- basename(httr::HEAD(download_url)$url)[[1]]
  wdpa_version(file_name)
}

Try the wdpar package in your browser

Any scripts or data that you put into this service are public.

wdpar documentation built on Sept. 21, 2023, 5:06 p.m.