bluegreen-labs / daymetr

An R Interface to the Daymet Web Services

Home Page:http://bluegreen-labs.github.io/daymetr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with spatial raster in daymetr::daymet_grid_tmean

sspelsberg opened this issue · comments

I'm currently taking the AGDS II class and this code snippet from "A handful of pixels" throws an error:

# Download daily temp data for bigger area
daymetr::download_daymet_tiles(
  tiles = 11935,
  start = 2012,
  end = 2012,
  param = c("tmin","tmax"),
  path = paste0(here::here(), "/data_raw/"),
  silent = TRUE
)

# calculate the daily mean values
r <- daymetr::daymet_grid_tmean(
  path = paste0(here::here(), "/data_raw/"),
  product = 11935,
  year = 2012,
  internal = TRUE
)

Error: [rast] cannot open this file as a SpatRaster: /Users/sophie/Documents/Uni/Master/AGDS/AGDS_course/data_raw/tmin_2012_11935.nc

Only catching this now, try to re-download things. The servers can be slow.

Also, carefully look at the paths (are the files downloaded in step one).

To be safe always use file.path() to create paths, or here::here() directly.

e.g. you could use

here:here("data-raw/") 

directly without the past argument.