# one pair of random coordinates from Africa
mat <- matrix(c(
-1.34, 42.96
), ncol=2, byrow=TRUE)
# repeat four times
mat<- mat[rep(1,4), ]
# assign default names and age
df<- data.frame(plng=mat[, 1],plat=mat[, 2], age=c(1,3,5, 1))
rownames(df) <- paste("point", 1:nrow(df))
# first coordinate pair will be extrated from RasterLayer 1 ["0"]
# second coordinate pair will be extracted from RasterLayer 3 ["10"]
# thrid coordinate pair will be extracted from RasterLayer 5 ["20"]
# fourth coordinate pair will be extracted from RasterLayer 1 ["0"]
data(dems)
extract(dems, df, by="age")
# by=NULL will be implemented in the next update
# (all coordinates extracted from all layers)
Run the code above in your browser using DataLab