Generate a multi-layer SpatRaster of day lengths for a given template.
The package geosphere
is required to use this function.
Usage
create_daylength_rst(
template,
dates = terra::time(template),
crs = "EPSG:4258",
.quiet = FALSE
)
Arguments
- template
(Multi-layer) SpatRaster that determines the spatial extent of the result.
- dates
Dates that should be processed. If not specified, the dates of
template
are used throughterra::time()
.- crs
Coordinate reference system with longitude/latitude metrics. It is used to project the raster coordinates to be able to retrieve the latitude.
- .quiet
If
TRUE
, messages are suppressed.
Examples
# \donttest{
# calculate day length, use barrks_data()$tmin as template
dl <- create_daylength_rst(barrks_data()$tmin, .quiet = TRUE)
# plot day length on May 1st, 2015
terra::plot(dl[[terra::time(dl) == '2015-05-01']])
# }