[RS-ecology] Issues running bfast

Ruben Soares Lapa Remelgado ruben.remelgado at uni-wuerzburg.de
Tue Mar 7 10:44:49 CET 2017


Dear Natalia,

The calc function comes from the raster package. Since the ts object does not have the 
same structure as a raster object the calc function can not read the
 data.

You can still use the calc function. But for that you need to split the ts object into single layers and add them to a
new stack. Something like

s = stack()
for (b in 1:nb) {s = addLayer(s, r[[b]])}

where nb is the number of bands and r is the ts object.

The optimal solution would be to use the period.apply() function of the rts package. It requires a ts object and works
like calc. To use it you need to specify the indices that define the start/end of the temporal window for which your
function should be applied. Please have a look at the following link for a quick example

https://www.rdocumentation.org/packages/rts/versions/1.0-18/topics/period.apply

Best,
Ruben


> -------- Forwarded Message --------
> Subject:     [RS-ecology] Issues running bfast
> Date:     Mon, 6 Mar 2017 12:28:35 -0500
> From:     Natalia Quinteros <natalia.l.quinteros.c at gmail.com>
> To:     rs-ecology at lists.uni-wuerzburg.de
>
>
>
> Hi List,
>
> I was doing the time series excersise of the book and I run into a problem:
>
> So this is my script:
>
> f_bfm <- function(x) {x <- ts(evi, start= c(2003, 1),frequency =46)
> bfm <- bfastmonitor(data = x, start = c(2010, 1))
> return(cbind(bfm$breakpoint, bfm$magnitude))
> }
>
> rbfm <- calc(evi, fun = function(x){
> t(apply(x,1,f_bfm))
> })
>
> When I run rbfm I receive this error:
>
> Error in (function (classes, fdef, mtable) :
> unable to find an inherited method for function ‘calc’ for signature
> ‘"ts", "function"’
>
> So, where is calc coming from? Is it coming from the package raster? Or
> what is the problem here?
>
> Thanks.
>
>
> Natalia L Quinteros Casaverde
> Ph.D Student
> Remote Sensing and Ecosystems Lab
> EEB - Biology
> City University of New York &
> Graduate Center
> CUNY
>
>
>

-- 
Dr. Martin Wegmann

University of Wuerzburg
Institute of Geography
Department of Remote Sensing
Remote Sensing and Biodiversity Research
Am Hubland
Oswald Kuelpe Weg 86
97074 Wuerzburg, Germany

German Aerospace Center (DLR)
German Remote Sensing Data Center (DFD)

Phone:  +49-(0)931-31 83446
Email:  martin.wegmann at uni-wuerzburg.de

url: http://www.geographie.uni-wuerzburg.de/en/fernerkundung_neu/startseite/
url: http://www.dlr.de/caf


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/attachments/20170307/c207dad3/attachment.html>


More information about the RS-ecology mailing list