Using upper quantile (default = 0.925) of multi-year MODIS data, determine the top NDVI for each id.

filter_top(DT, probs = 0.925, id = "id")

Arguments

DT

data.table of NDVI time series

probs

quantile probability to determine top. default is 0.925.

id

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

Value

filtered data.table with appended 'top' column of each id's top (quantile) NDVI value.

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", "sampled-ndvi-MODIS-MOD13Q1.csv", package = "irg"))

filter_qa(ndvi, ndvi = 'NDVI', qa = 'SummaryQA', good = c(0, 1))
#>      id   NDVI SummaryQA DayOfYear   yr filtered
#>   1:  0 0.1864         3        11 2015       NA
#>   2:  1 0.0541         2         3 2015       NA
#>   3:  2 0.1781         3        11 2015       NA
#>   4:  3 0.1024         2         5 2015       NA
#>   5:  4 0.0898         2         3 2015       NA
#>  ---                                            
#> 801:  2 0.1179         2       364 2019       NA
#> 802:  3 0.0789         2       364 2019       NA
#> 803:  4 0.1572         2       364 2019       NA
#> 804:  5 0.0763         2       364 2019       NA
#> 805:  6 0.1197         2       362 2019       NA
filter_winter(ndvi, probs = 0.025, limits = c(60L, 300L), doy = 'DayOfYear', id = 'id')
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150
#>  ---                                                       
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325
filter_roll(ndvi, window = 3L, id = 'id')
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter    rolled
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500 0.3076500
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400 0.3163400
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875 0.2649875
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750 0.2301750
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150 0.2177150
#>  ---                                                                 
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875 0.2649875
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750 0.2301750
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150 0.2177150
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400 0.3163400
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325 0.3149325
filter_top(ndvi, probs = 0.925, id = 'id')
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter    rolled       top
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500 0.3076500 0.8735000
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400 0.3163400 0.8632175
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875 0.2649875 0.8707500
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750 0.2301750 0.8635525
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150 0.2177150 0.8476000
#>  ---                                                                           
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875 0.2649875 0.8707500
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750 0.2301750 0.8635525
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150 0.2177150 0.8476000
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400 0.3163400 0.8632175
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325 0.3149325 0.8632000