I am using R language and I would like to create a NDVI time series plot, NDVI vs time, based on irregular intervaled landsat images. I have found a method to create a raster stack and plot the average NDVI of the total area over time. Average NDVI is okay, but i would like to plot for a selected point (pixel based or xy coordinate) within the area.

Any suggestion? I am very new to R so a step by step explanation would be really helpful


1 Answer 1


Do you want an interactive map, or are you fine with plotting the NDVI timeseries for one (or few) specific points? In the latter you raster::extract() the NDVI-Stack values under your points, and use the returned dataframe as input for your plot.


I was thinking... You actually can do some interactive point-selection using raster::click(). So as a little example I just wrote this for you:

# Sample Dataset
year2000 <- raster(nrows=10, ncols=10, vals=runif(100, -1,1))
year2005 <- raster(nrows=10, ncols=10, vals=runif(100, -1,1))
year2010 <- raster(nrows=10, ncols=10, vals=runif(100, -1,1))
year2015 <- raster(nrows=10, ncols=10, vals=runif(100, -1,1))

NDVI.stack <- stack(year2000, year2005, year2010, year2015)  # Representing your layerstack

# Plot Stack, select point and automaticly extract values
plot(NDVI.stack[[1]])  # One exemplary layer for orientation
values <- click(NDVI.stack, n=1)

# Compose and plot dataframe
timeseries <- data.frame(year = c(2000, 2005, 2010, 2015),
                         values = values[1, ])
plot(timeseries, type="l")

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.