Using a rolling median, filter the NDVI time series for each id.

filter_roll(DT, window = 3L, id = "id", method = "median")

Arguments

DT

data.table of NDVI time series

window

window size. default is 3.

id

id column. default is 'id'. See details.

method

median. no other options yet. let me know if you are looking for something else.

Value

filtered data.table with appended 'rolled' column of each id's rolling median, filtered NDVI time series.

Details

The id argument is used to split between sampling units. This may be a point id, polygon id, pixel id, etc. depending on your analysis.

See also

Examples

# Load data.table library(data.table) # Read example data ndvi <- fread(system.file("extdata", "ndvi.csv", package = "irg")) filter_qa(ndvi, qa = 'SummaryQA', good = c(0, 1)) filter_winter(ndvi, probs = 0.025, limits = c(60L, 300L), doy = 'DayOfYear', id = 'id')
#> id yr DayOfYear NDVI SummaryQA filtered winter #> 1: 7652 2002 3 -1367 3 4099 4099 #> 2: 7035 2002 14 -304 3 5382 5382 #> 3: 4368 2002 1 374 2 3702 3702 #> 4: 5196 2002 15 635 3 5180 5180 #> 5: 12377 2002 9 685 2 4621 4621 #> --- #> 2526: 13322 2012 356 1257 2 4708 4708 #> 2527: 9537 2012 356 144 2 4536 4536 #> 2528: 18592 2012 362 1031 2 4011 4011 #> 2529: 2163 2012 356 2172 2 5022 5022 #> 2530: 2941 2012 356 -197 2 2839 2839
filter_roll(ndvi, window = 3L, id = 'id')
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled #> 1: 7652 2002 3 -1367 3 4099 4099 4099 #> 2: 7035 2002 14 -304 3 5382 5382 5382 #> 3: 4368 2002 1 374 2 3702 3702 3702 #> 4: 5196 2002 15 635 3 5180 5180 5180 #> 5: 12377 2002 9 685 2 4621 4621 4621 #> --- #> 2526: 13322 2012 356 1257 2 4708 4708 4708 #> 2527: 9537 2012 356 144 2 4536 4536 4536 #> 2528: 18592 2012 362 1031 2 4011 4011 4011 #> 2529: 2163 2012 356 2172 2 5022 5022 5022 #> 2530: 2941 2012 356 -197 2 2839 2839 2839