calc_nd | R Documentation |
Function to count the number of days in a given time period that meet a given set of criteria. This can be used to extract indices such as Growing Degree Days (tmin > 0), or days with precipitation (prcp != 0).
calc_nd(
file,
start_doy = 1,
end_doy = 365,
criteria,
value,
internal = FALSE,
path = tempdir()
)
file |
path of a file containing the daily gridded Daymet data |
start_doy |
numeric day-of-year at which counting should begin. (default = 1) |
end_doy |
numeric day of year at which counting should end. (default = 365) |
criteria |
logical expression (">=",">","<=","<","==", "!=") to evaluate |
value |
the value that the criteria is evaluated against |
internal |
return to workspace ( |
path |
path to which to write data to disk (default = tempdir()) |
A raster object in the R workspace or a file on disk with summary statistics for every pixel which meet the predefined criteria. Output files if written to file will be named nd_YYYY.tif (with YYYY the year of the processed tile or ncss netCDF file).
## Not run:
# download daily gridded data
# using default settings (data written to tempdir())
download_daymet_ncss()
# read in the Daymet file and report back the number
# of days in a year with a minimum temperature lower
# than 15 degrees C
r <- calc_nd(file.path(tempdir(),"tmin_daily_1980_ncss.nc"),
criteria = "<",
value = 15,
internal = TRUE)
# plot the output
terra::plot(r)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.