I have a list of rasters of the same location for multiple years. The change in pixel value over time represents the time series of pixel. To further analyses, I need to extract the values over time per every pixel, and store it in data frame, where row = #pixel, column = year
Dummy data:
library(raster)
# create raster data from scratch
# create empty raster
y1<-raster(ncol = 3, nrow = 3)
values(y1)<-1:9
projection(y1)<-CRS("+init=epsg:4326")
# create and diversify the rasters
y2<-y1+10
y3<-y1+20
y4<-y1+30
# make list of rasters
y.list<-list(y1, y2,y3,y4)
# plot all rasters at once
par(mfrow = c(2,2))
for(i in 1:length(y.list)) {
plot(y.list[[i]])
}
How the dataframe should look like:
y1 y2 y3 y4
pixel1 1 10 20 30
pixel2
...
pixel9 9 19 29 39
How to extract unique pixel values over time, and convert individual pixel data to data frame??