Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMAG, SDIFF and SLP #76

Open
smithve87 opened this issue Aug 7, 2017 · 4 comments
Open

BMAG, SDIFF and SLP #76

smithve87 opened this issue Aug 7, 2017 · 4 comments

Comments

@smithve87
Copy link

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!

@loicdtx
Copy link
Owner

loicdtx commented Aug 7, 2017

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.

@smithve87
Copy link
Author

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
Copy link
Author

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!

@loicdtx
Copy link
Owner

loicdtx commented Aug 8, 2017

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants