[Bfast-commits] FW: Running bfast on raster bricks
Jan Verbesselt
janverbesselt at gmail.com
Fri Mar 22 17:18:42 CET 2013
I have updated the bfast package and included a working example in the
bfastmonitor example.
Please see ?bfastmonitor
install bfast via
http://r-forge.r-project.org/R/?group_id=533
after the weekend then the new details will be available.
Let me know if you have specific questions.
Best,
Jan
On Mon, Feb 18, 2013 at 5:08 PM, Polyanne Aguiar
<polyanneaguiar at gmail.com>wrote:
> ** **
>
> Hello,****
>
> ** **
>
> I am using the bfast in my jobs. But, I am attempting run the bfastmonitor
> on a raster brick (time serie MODIS EVI), I not get.****
>
> I followed the script proposed by you in this forum. But I did not
> succeed.****
>
> ** **
>
> Following is the script used:****
>
> ** **
>
>
> ################################################################################
> ****
>
> ** **
>
> ## TUTORIAL for processing raster bricks (satellite image time series of
> 16-day NDVI images)****
>
> ** **
>
> file<- brick("MT_micro.tif", native, package="raster")****
>
> file****
>
> ** **
>
> ## helper function for the calc function ****
>
> xbfast <- function(file) {****
>
> ndvi <- ts(file, frequency=23, start=c(2000,9))****
>
> result <- bfast(ndvi, season="harmonic", max.iter=1, breaks=2)****
>
> return(cbind(result$Magnitude,result$Time)) ## save magnitude and
> time of the biggest break ****
>
> }****
>
> ** **
>
> ## apply on a single pixel for testing****
>
> pixel <- as.vector(file[50])****
>
> ndvi <- ts(pixel, frequency=23, start=c(2000,9))****
>
> plot(ndvi)****
>
> result <- bfast(ndvi, season="harmonic", max.iter=1, breaks=2)****
>
> plot(result)****
>
> ** **
>
> ** **
>
> ## apply on a single pixel using the xbfast function ****
>
> output <- xbfast(pixel)****
>
> output****
>
> ****
>
> ** **
>
> ## optimise function that takes into account the percentage of NA's within
> a time series ****
>
> bfastfun <- function(y) {****
>
> percNA <- apply(y, 1, FUN=function(x) (sum(is.na(x))/length(x)) )
> ## checks the percentage of NA's with the time series****
>
> i <- (percNA<0.2)****
>
> res <- matrix(NA, length(i), 2)****
>
> if (sum(i) > 0) {****
>
> res[i,] <- t(apply(y[i,], 1, xbfast))****
>
> }****
>
> res****
>
> }****
>
> ** **
>
> ##apply on the full satellite image time series ****
>
> magntime <- calc(data, fun=bfastfun)****
>
> layerNames(magntime) <- c("Magnitude", "Time of biggest Break")****
>
> plot(magntime)****
>
> ** **
>
> ## two rasters are returned: i.e. the magnitude and time of the biggest
> break ## WARNING: this is requires some time :-).****
>
> ** **
>
>
> ###############################################################################################
> ****
>
> ** **
>
> Thanks,****
>
> ** **
>
> ** **
>
> Polyanne Aguiar dos Santos****
>
> Master in Applied Ecology – UFLA****
>
> Specialist in Environmental Management – UNISAM****
>
> Biologist – ESFA****
>
> Phone: +55 35 9178 3275****
>
> Skype: polyanne.aguiar****
>
> ** **
>
> [image: cid:image001.png at 01CDF3FB.781F9910]****
>
> ** **
>
> ** **
>
> _______________________________________________
> Bfast-commits mailing list
> Bfast-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/bfast-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/bfast-commits/attachments/20130322/236a5f3b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 11326 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/bfast-commits/attachments/20130322/236a5f3b/attachment-0001.png>
More information about the Bfast-commits
mailing list