-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
project.org] On Behalf Of Navinder Singh
Sent: 22. oktober 2014 23:57
To: r-sig-geo at r-project.org
Cc: oscar.perpinan at upm.es
Subject: [R-sig-Geo] Overlaying time designated spatial points from a data
frame to match the time of a raster image in a rasterStack
Hi,
I have a level plot with a number of rasters (monthly rasters for a year-
generated with kind help from Oscar). Basically a raster stack.
I would like to overlay spatial points on this raster stack, but would like to
overlay only those points that belong to the month matching the raster stack.
For e.g. The points form January should fall on the raster from January, those
from february should fall on February raster as so on. I am drowning in the
?lattice' literature but have not succeeded till now.
I am running the following code but not sure how to assign an index which
can delegate the points from respective months to their rasters in the layer +
sp. points argument from rasterVis package.
My data frame has the following columns:
df= X, Y, date (POSIXct), month (month.abb), id (animalID), SITE (a factor
with origin area)
The rasters also have names in the format of month.abb.
And the code i am using is:
rrMean is a raster stack of monthly means. dfSp is a SpatialPointDataFrame
with above fields.
p<-levelplot(rrMean, main="Mean Monthly NDVI (2010-2014)",
par.settings=myTheme)
p+layer(sp.points(dfSp,col=dfSp$SITE))
# I understand that col argument just changes the colours but still plots all
points on all rasters, but i guess i need something specified
in sp.points(dfSp,col=dfSp$SITE).
Thanks for any suggestions.
Best wishes,
Navinder
email: navinder.singh at slu.se<mailto:navinder.singh at slu.se>
[[alternative HTML version deleted]]