4

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

1 Answer 1

6

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.


Edit:

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:

library(raster)
# 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")
0

Your Answer

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

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