I am downloading tree cover spatial data using the 'dataverse' package and attempting to save it as a RasterStack. The download is fine, however when I use writeRaster to save it, I get the following error message: "Error in .local(.Object, ...) :"
I set it up as a function to ideally download and save each year. I've reviewed many forums, but none of the fixes applied have worked. I've been able to save other, test RasterStacks with the writeRaster function, but not mine. Any idea what the issue is?
library(dataverse)
library(raster)
setwd("C:/Users/Kate/Documents/ScottRiver/ShastaScottStateOfBasin/Data/Dataverse/")
downloaddataverse <- function(year){
thedf <-
get_dataframe_by_name(
filename = paste0("ARD_h02v06_C2_",year,"_vegCover.tif"),
dataset = "10.7910/DVN/KMBYYM",
server = "dataverse.harvard.edu",
.f = raster,
original=T)
}
df1990 <- stack(downloaddataverse(1990))
writeRaster(df1990,"df1990.tif",overwrite=T)