loicdtx / bfastSpatial

Set of utilities and wrappers to perform change detection on satellite image time-series (Landsat and MODIS). Includes pre-processing steps and functions for spatial implementation of bfastmonitor change detection and post processing of the results.
93 stars 39 forks source link

An error occurred using bfmPixel #81

Closed tudoudunpaigu closed 6 years ago

tudoudunpaigu commented 6 years ago

Hello! I'm trying to repeat the codes from the tutorial. when it came to the 'bfmPixel' step, it took my computer more than 24 hours to run the code and finally it return an error : Error in x[cell] : object of type 'S4' is not subsettable. qq 20180307111809

bendv commented 6 years ago

You should get a result immediately with bfmPixel(). What exactly is ndviStack in this example? Can you tell me what steps you took to create it? Can you get bfmPixel() to work on the tura dataset as in the tutorial?

tudoudunpaigu commented 6 years ago

The codes I run is from the bfastSpatial Peru(https://changemonitor-wur.github.io/talks/bfastSpatial-2016/bfastSpatial_Peru.html). The ndviStack is a RasterBrick created from hungaryData.tar.gz. I wrote these codes to test tura dataset: "library(bfast) library(bfastSpatial) data(tura) tura plot(tura, 94) bfmPixel(x = tura, start = 1984, formula=response~harmon, order=1, history = c(2008, 7), interactive = TRUE, plot = TRUE)" 10 hours past and I still didn't get a result. I've seen this error a couple of times. Before running the bfastSpatial codes, I used bfast to process GIMMS data and I succeed. Then I tried to use BfastSpatial on GIMMS data, I created a dataset just like tura and ndviStack, it returned a error:Error in x[cell] : object of type 'S4' is not subsettable. Did I forget to "library" an important function?

bendv commented 6 years ago

The tura test works perfectly for me on a fresh install of bfastSpatial, so the only thing I can think of is you are not actually choosing the pixel -- ie., if you set interactive to TRUE, you need to click on the plot in the plot window to choose a pixel to view. If you don't click on a pixel from the plot, nothing will happen.

Or if you already know the ID of the pixel you want to view, you need to set cell to a cell number and interactive to FALSE.

I also noticed that you are setting your monitoring period (start=1984) to before the start of the history period (history=c(2008, 7)), which doesn't make sense and will throw an error. tura doesn't have any data before 1984, so I wouldn't set the monitoring period to that date. Perhaps you meant to set them the other way around?

GIMMS data are not supported with bfmPixel - you will have to stick to the bfast package for now if you are working with GIMMS