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"
)

Arguments

x

object obtained from the extrat_nc_value function or a rasterBrick with dates as layers

y

point to extract values, must be an sf (sf), a SpatVect (terra) or spatialPointDataFrame object (sp)

agg_function

function used to aggregate data, "mean" or "sum"

variable_name

character string to identify the resulting variable

time_step

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.

win_length

integer length of the temporal window to apply the rolling function

site_col

character string with the name of column containing site_id in object "y". Default is "site_id"

Details

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.

Author

Reto Schmucki