<html><head><meta http-equiv=Content-Type content="text/html; charset=UTF-8"><META name="Author" content="GroupWise WebAccess"><style type="text/css"> 
body p 

        margin: 0px; 
}
</style></head><body style='font-family: Helvetica, Arial, sans-serif; font-size: 13px; '><div id="GroupWiseSection_1488879193000_ruben.remelgado@uni-wuerzburg.de_84CF32811548000097E75698249E046B_" class="GroupWiseMessageBody">Dear Natalia,<br><br>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.<br><br>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<br><br><b>s = stack()<br>for (b in 1:nb) {s = addLayer(s, r[[b]])}</b><br><br>where <b>nb</b> is the number of bands and <b>r</b> is the ts object.<br><br>The optimal solution would be to use the <b>period.apply()</b> function of the <b>rts</b> 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<br><br><a href="https://www.rdocumentation.org/packages/rts/versions/1.0-18/topics/period.apply">https://www.rdocumentation.org/packages/rts/versions/1.0-18/topics/period.apply</a><br><br>Best,<br>Ruben<br><br><br>> -------- Forwarded Message --------<br>> Subject:     [RS-ecology] Issues running bfast<br>> Date:     Mon, 6 Mar 2017 12:28:35 -0500<br>> From:     Natalia Quinteros <natalia.l.quinteros.c@gmail.com><br>> To:     rs-ecology@lists.uni-wuerzburg.de<br>><br>><br>><br>> Hi List,<br>><br>> I was doing the time series excersise of the book and I run into a problem:<br>><br>> So this is my script:<br>><br>> f_bfm <- function(x) {x <- ts(evi, start= c(2003, 1),frequency =46)<br>> bfm <- bfastmonitor(data = x, start = c(2010, 1))<br>> return(cbind(bfm$breakpoint, bfm$magnitude))<br>> }<br>><br>> rbfm <- calc(evi, fun = function(x){<br>> t(apply(x,1,f_bfm))<br>> })<br>><br>> When I run rbfm I receive this error:<br>><br>> Error in (function (classes, fdef, mtable) :<br>> unable to find an inherited method for function ‘calc’ for signature<br>> ‘"ts", "function"’<br>><br>> So, where is calc coming from? Is it coming from the package raster? Or<br>> what is the problem here?<br>><br>> Thanks.<br>><br>><br>> Natalia L Quinteros Casaverde<br>> Ph.D Student<br>> Remote Sensing and Ecosystems Lab<br>> EEB - Biology<br>> City University of New York &<br>> Graduate Center<br>> CUNY<br>><br>><br>><br><br>-- <br>Dr. Martin Wegmann<br><br>University of Wuerzburg<br>Institute of Geography<br>Department of Remote Sensing<br>Remote Sensing and Biodiversity Research<br>Am Hubland<br>Oswald Kuelpe Weg 86<br>97074 Wuerzburg, Germany<br><br>German Aerospace Center (DLR)<br>German Remote Sensing Data Center (DFD)<br><br>Phone:  +49-(0)931-31 83446<br>Email:  martin.wegmann@uni-wuerzburg.de<br><br>url: http://www.geographie.uni-wuerzburg.de/en/fernerkundung_neu/startseite/<br>url: http://www.dlr.de/caf<br></div></body></html>