gis - Plot specific point data on each layer in stack with rasterVis in R -
i have 2 rasters stacked together:
library(rastervis) r1 <- raster(system.file("external/test.grd", package="raster")) r2 <- r1 / 2 r.stack <- stack(r1, r2)
since highlight areas later each specific layer in stack, create 2 point datasets based on raster values:
pts1 <- rastertopoints(r1, spatial=t) idx <- which(as.data.frame(pts1)[, 1] >= 400) pts1 <- pts1[idx, 1] pts2 <- rastertopoints(r2, spatial=t) idx <- which(as.data.frame(pts2)[, 1] >= 400) pts2 <- pts2[idx, 1]
now, plot raster stack levelplot rastervis in r. overlay r1 pts1 , r2 pts2.
however, add 1 point dataset, used both layers:
levelplot(r.stack) + layer(sp.points(pts1, pch=20, cex=0.1, col="black"))
how can use specific point datasets specific layers while still using raster stacks?
i avoid making own subplot plotting each layer its' specific point dataset alone followed using print.trellis. tried it, result inferior compared levelplot raster stacks.
any idea on how achieve that?
with panel.number
function can subset data according panel located:
pts <- list(pts1, pts2) levelplot(r.stack) + layer(sp.points(pts[[panel.number()]], pch=20, cex=0.1, col="black"))
Comments
Post a Comment