Compute mean climatic values for specific periods from an object obtained from the extrat_nc_value function
temporal_aggregate(
x,
y = NULL,
agg_function = "mean",
variable_name = "average temp",
time_step = c("annual", "monthly", "daily", "window"),
win_length = NULL,
site_col = "site_id"
)
object obtained from the extrat_nc_value function or a rasterBrick with dates as layers
point to extract values, must be an sf (sf), a SpatVect (terra) or spatialPointDataFrame object (sp)
function used to aggregate data, "mean" or "sum"
character string to identify the resulting variable
character string defining the level of averaging, "annual", "monthly" or "window"; if time_step = "window" the rolling function is returned, computed over the temporal window defined by "wind_length". time_step = "daily" will return the daily value, per point if points are provided in y.
integer length of the temporal window to apply the rolling function
character string with the name of column containing site_id in object "y". Default is "site_id"
The output is either a multilayer raster if no points are supplied in y or a data.table with aggregated statistic computed for each point provided in y. If points provided fall in areas with no data (e.g. in the sea along the coast), the function will search for the nearest value available, up to 3 cell in each direction. A distance (m) between the point and the raster cell used to retrieve the climate metric is calculated and documented in the data output. If the point is within a cell with value, the distance is set to NA.