1

I have MODIS ndvi data (MODIS_Grid_16 days NDVI) from the iberian peninsula (3 tiles), from February of 2000 to August of 2012 (really big data). I want to know how to deal with this kind of files.
My final goal is to extract the ndvi value to points with a associated date, i.e., I have sequencial dated points and I want to know the value of ndvi to that date point.)

How do I (automatically) merge the 3 tiles that compose the iberian peninsula for each 16-days (2000-2012)?
(I think if I use R to identify each filename and use gdal merge, it might work, but maybe there's a simplier way)

How do I create a time series from it and extract the values associated?

1 Answer 1

4

You can use the "stack" or "brick" function(s) in the raster package to create a single raster object of your NDVI time-series. The names of each NDVI file will be retained in the object and the rasters will be held out-of-memory, making it memory safe.

You can then retrieve the raster values, associated with a point feature, across the series using the "extract" function. Here is a mock example:

require(raster)
require(rgdal)
require(sp)

setwd("C:/data")

# Read points
  pts <- readOGR(getwd(), "MyPoints")

# Create raster stack using wildcard in list.files
ndvi.files <- list.files(getwd, pattern="img$", full.names=FALSE)
  ndvi <- stack(ndvi.files)

# Extract point values and merge with sp point object 
pts@data <- data.frame(pts@data, extract(ndvi, pts) )
  str(pts@data)

After you have the ndvi values extracted, you could apply the date functionality in R to the names of the ndvi file names (retained in extract) associated with each column. In this way you can write functions to analyze the time-series. Also, keep in mind that you can apply functions to the raster stack itself using the "overlay" function.

2
  • 1
    Thank you so much for the answer! It seems pretty easy to handle this amount of data, but I've some doubts about it. My ndvi files are in .hdf format, and it seems that stack function can't handle this file format. Does this function merge raster files both in time and space?
    – JMarcelino
    Commented Mar 18, 2014 at 15:49
  • 1
    I often use hdf files in the raster package so, there must be a different issue going on. In fact, I have performed exactly this type of analysis, 10 year with 16 day composts, with MODIS ndvi and npp products. If I understand you, the hdf tiles are handled independently and you cannot merge adjacent tiles without a specialized function. The stack represents a single spatial domain with the rasters representing the temporal domain. This is a common data structure for climate data as well. Have you processed the data and reprojected it from a Sinusoidal projection? Commented Mar 18, 2014 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.