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

cleanMODIS QC_value documentation is not clear #56

Closed bogitamat closed 8 years ago

bogitamat commented 9 years ago

Using processMODISbatch to clean MOD13Q1 on Indonesian NDVI leaves only 25 values from 2002 - 2014. Could it be the QC_value? I am using the one mentioned in the example, i.e. 0x19 (QC_SDS=3). Documenting the use of QC_value for different MODIS products would be very helpful!

best

loicdtx commented 9 years ago

There is no right or wrong way to clean the data, it depends what the user wants to achieve, so it is not so easy to give example for every dataset. Though 0x19 would be a very strange mask for MOD13Q1.

Looking at the product description, a simple way to clean using the QC layer would be to use either QC_val = 0x2 or QC_val = 0x3. If you want to apply more detailed cleaning, based on aerosols, adjacent clouds, BRDF, etc ... you have to look into higher bits. For instance QC_val = 0x8003 will retain only good quality data, except if it is snow or ice. But ice is probably not a big issue in Indonesia. Note that this product also has a pixel reliability layer (12th SDS), so the 'simple cleaning' mentioned above can also be achieved using something like:

# Keep only good quality data
cleanMODIS(x, data_SDS = 1, QC_SDS = 12, bit=FALSE, QC_val = 0, fill= -3000)

or

# Keep good and marginal quality data
cleanMODIS(x, data_SDS = 1, QC_SDS = 12, bit=FALSE, QC_val = c(0,1), fill= -3000)
bogitamat commented 9 years ago

Hi Loïc,

Thank you so much for the super fast and very helpful reply

Thanks to your clear answer, now I understand how the QC_val works. I can put all the qualities I need together to form the 16 bit, then convert it to hexadecimal number, which could be used as an input for QC_val

I will use the cleaned values as input for bfastSpatial, but just for display, would you recommend a specific interpolation technique (also in R) for the cleaned data? Would something like linear interpolation (using approxfun) make sense?

have a nice weekend! bogi

loicdtx commented 9 years ago

You're welcome, In which dimension do you want to interpolate? Spatial, temporal or both? Temporal interpolation is probably a reasonable choice if you don't have too much missing data. It makes sense (temporal auto-correlation) and is quite easy to achieve using e.g. na.approx from the zoo package (you'll have to write your own function with calc{raster}). More advanced approaches for that particular purpose exist as well but that's probably an overkill if it's 'just' for display.

bogitamat commented 8 years ago

Hi Loïc, Temporal resolution only, as you thought. But I do have a lot of missing data. I have tested a couple of interpolation techniques, but the advanced approach you suggested seems better. Is there an R package that does the fourier or discrete wavelet transformation?

It is definitely a lot of work, but a must in my case!

loicdtx commented 8 years ago

Hi Bogi,

We're going off topic, let's continue the discussion off the bug tracker. Just send me an email an I can help you there.

Cheers,