Compute a vector of indices of "year" or "month" based on the date extracted from the SpatRaster or a vector of strings over the time period.

get_layer_indice(
  x = NULL,
  pattern = NULL,
  date_format = "%Y-%m-%d",
  indice_level = "year",
  week_start = getOption("lubridate.week.start", 1)
)

Arguments

x

SpatRaster or a vector of dates, from which to extract the dates of the time-series.

pattern

string or characters to remove from the date name (e.g. remove the character "X" from "X2001.07.15"), default is null.

date_format

format of the date

indice_level

string to define the time-period to use to define the indices, "year" or "month".

week_start

option of lubridate starting day of the week, where 1 is Monday and 7 is Sunday.

Details

This function generate a vector of indices dividing the time-series in years or months. This indices are use for the calculating the cummulative sum over years or month (see function cumsum_rb()).

Author

Reto Schmucki