R/load_copNDVI.R

Defines functions load_copNDVI

Documented in load_copNDVI

#' Load Copernicus NDVI data
#'
#' This function loads and returns the Copernicus Long Term (1999-2017) NDVI Overview stored within the package.
#'
#' @return A `SpatRaster` object representing the Copernicus NDVI data.
#' @export
load_copNDVI <- function() {
  # Set the path to the RDS file
  rds_file <- system.file("extdata", "copNDVI.rds", package = "rasterdiv")
  
  # Check if the file exists
  if (file.exists(rds_file)) {
    # Load the SpatRaster object from the RDS file
    copNDVI <- terra::rast(readRDS(rds_file))
  } else {
    stop("Data file 'copNDVI.rds' not found in the package.")
  }
  
  return(copNDVI)
}

Try the rasterdiv package in your browser

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

rasterdiv documentation built on Oct. 14, 2024, 5:10 p.m.