R software : How to extract values from rasterstack with xy coordinates?

Posted by Eddie on Stack Overflow See other posts from Stack Overflow or by Eddie
Published on 2013-11-07T10:41:41Z Indexed on 2013/11/07 21:55 UTC
Read the original article Hit count: 161

Filed under:
|

I have a rasterstack(5 raster layers) that actually is a time series raster.

r <- raster(nrow=20, ncol=200)
s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3) )) )
> s

class       : RasterStack
dimensions  : 20, 200, 4000, 5  (nrow, ncol, ncell, nlayers)
resolution  : 1.8, 9  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
names       :   layer.1,   layer.2,   layer.3,   layer.4,   layer.5
min values  : -9.012146, -9.165947, -9.707269, -7.829763, -5.332007
max values  :  11.32811,  11.97328,  15.99459,  15.66769,  16.72236

My objective is to plot each pixel and explore their behavior over time.

How could I extract each pixels together with their x,y coordinates and plot a time series curve?

© Stack Overflow or respective owner

Related posts about r

    Related posts about extract