bfastSpatial icon indicating copy to clipboard operation
bfastSpatial copied to clipboard

BMAG, SDIFF and SLP

Open smithve87 opened this issue 8 years ago • 4 comments

I am working with bfast and bfastSpatial in my research and came across the work of Grogan et al. in "Mapping Clearances in Tropical Dry Forests Using Breakpoints, Trend, and Seasonal Components from MODIS Time Series: Does Forest Type Matter?" In their work they used the break magnitude (bmag) (a); the seasonal amplitude difference (sdiff) (b); and the most negative slope (slp) of the first (slp1) and second (slp2) trend segment (c) - see attached image.

grogan 2016

I know that bmag is a default output layer for bfastSpatial, but can sdiff and slp be acquired from bfastSpatial output layers? I've just started looking into the returnLayers argument and adding the other layers (r.squared, X.Intercept, harmoncos, etc.), but I'm not really sure if this is what I need for sdiff and slp.

I'm just wondering if anyone has dealt with this before and what the best means of acquiring these output variables would be. Please let me know, and I'll look forward to hearing back, thanks!

smithve87 avatar Aug 07 '17 19:08 smithve87

This algorithm is actually different from what is implemented in bfmSpatial (bfast::bfasmonitor vs strucchange::breakpoints). sdiff and slp cannot be retrieved from what's currently implemented in bfastSpatial and bmag probably also differ from what is described in this article.

The feature-bp branch contains some dirty code to run breakpoints at feature level and extract some similar metrics. It was used for this project. I'm planning some day to clean this up and integrate it into the main bfastSpatial but I'm not sure when I'll get to do it.

loicdtx avatar Aug 07 '17 22:08 loicdtx

I understand. I have been working a bit with bfast and bfastmonitor as well, but am having trouble with the rasterbrick vs time series object dynamic, as bfast and bfastmonitor require ts objects. I've tried multiple methods - making rasterbrick a ts object via rts, attempting to coerce rasterbrick with as.ts, etc. However, bfast and bfastmonitor always have issue with the input either not being a ts object or issues with S4 objects. Could you provide some suggestions as to how to get the rasterbrick into the proper format for bfast/bfastmonitor to analyze?

smithve87 avatar Aug 08 '17 17:08 smithve87

To update, I've been able to create a time-series object with bfastts, but it is of a single pixel and contains NA values, which bfast won't accept. It will run in bfastmonitor, but the output is incorrect. Iterating bfast for every ts pixel wouldn't be too difficult, I'm just unclear on how to get the ts object in the proper format to run at all in bfast, and run properly in bfastmonitor. Let me know and I can send my steps /code thus far. Any help is much appreciated thanks!

smithve87 avatar Aug 08 '17 20:08 smithve87

bfastmonitor is already implemented spatially in bfmSpatial (for RasterBricks/Stacks). Check the source code to see how the spatial implementation works and you may follow the same logic for bfast or breakpoints, only that for these functions it makes sense to have a variable number of output depending on the number of breaks detected. So you have to decide which values from the bfast object are valuable to you and make sure the function passed to raster::calc always returns the same number of outputs (even when it crashes).

loicdtx avatar Aug 08 '17 21:08 loicdtx