R/gedi_getdate.R

Defines functions gedi_getdate

Documented in gedi_getdate

#' GEDI get date from filename
#'
#' This function get's the date from the filenmae as julian and as YYYY-MM-DD
#' @param file_nm filename as characterstring
#'
#' @keywords name date
#' @export
#' @examples
#' gedi_getdate()
#'
#' @import chron

gedi_getdate <- function(file_nm){
  splt <- strsplit(file_nm, "_")[[1]]
  orbit_datetime <- splt[3]
  year <- as.numeric(substring(orbit_datetime, 1,4))
  jul_dat <- as.numeric(substring(orbit_datetime, 5,7))
  gedi_date <- chron::month.day.year(jul = jul_dat, origin = c(1,1,year))
  return(gedi_date)
}
envima/GEDItools documentation built on July 25, 2020, 5:13 p.m.