How to obtain Dates of annual maximum gridcell values of rasterbrick?

前端 未结 1 1156
北海茫月
北海茫月 2021-01-26 08:36

How can i get two rasters that gives the maximum value for each grid cells per year and also gives the dates on which that maximum value has occured. Below is the reproducible e

相关标签:
1条回答
  • 2021-01-26 09:15

    You can do

    wmax <- stackApply(r.dt, indices = indices, fun=function(i,...) which.max(i))
    

    to get the indices that refer to the Date vector

    To get (integer) date representations, i.e., the number of days since 1970-01-01, you could do something like this, for each year

    m2000 = data.frame(from=1:3, to=as.integer(Date_val)[1:3])
    x <- subs(wmax[[1]], m2000)
    
    0 讨论(0)
提交回复
热议问题