[R-sig-Geo] rastervVis : adding point locations to a hovmoller plot
Oscar Perpiñán Lamigueiro
oscar.perpinan at upm.es
Thu Jan 30 10:44:39 CET 2014
Hello,
The easiest solution is using the +.trellis function provided by the
latticeExtra package (automatically loaded with rasterVis). I have
modified a bit your example to show the usage:
idx <- seq(as.Date('2008-01-15'), as.Date('2008-3-15'), 'month')
SISmm <- setZ(St, idx)
hov <- hovmoller(SISmm, contour=FALSE, panel=panel.levelplot.raster,
yscale.components=yscale.raster.subticks,
interpolate=TRUE,
par.settings=RdBuTheme)
#location data in decimal degrees. these are the points I want to add onto the hovmoller plot
x <- c(50 , 25, 0)
date <- as.Date(c('2008-01-15', '2008-02-15','2008-03-15'))
loc <- data.frame(x, date)
## Here we use +.trellis to overlay the points
hov + xyplot(date ~ x, data=loc)
Best,
Oscar.
Don Carlos writes:
> Dear r sig geo users,
>
> I trying to add location points (longitude-time) onto a hovmoller plot
> (rasterVis). These are locations of objects at given longitude and time.
>
> An example of what I want to do here
>
> library("rasterVis")
> library("lattice")
> r <- raster(nrows=10, ncols=10)
> r <- setValues(r, 1:ncell(r))
> r1 <- raster(nrows=10, ncols=10)
> r1 <- setValues(r1, 1:ncell(r))
> r2 <- raster(nrows=10, ncols=10)
> r2 <- setValues(r2, 1:ncell(r))
> St=stack(r,r1,r2)
> idx <- seq(as.Date('2008-01-15'), as.Date('2008-1-17'), 'day')
> SISmm <- setZ(St, idx)
> hov<-hovmoller(SISmm, contour=FALSE, panel=panel.levelplot.raster,
> yscale.components=yscale.
> raster.subticks,interpolate=TRUE,
> par.settings=RdBuTheme)
>
> #location data in decimal degrees. these are the points I want to add onto
> the hovmoller plot
> x<-c(50.00000,25.00000,0.00000)
> date<-as.Date('2008-01-15', '2008-01-15','2008-01-17')
> loc<-data.frame(x,date)
>
> #attempt to overlay the location onto the hov plot. This is clearly not the
> correct approach but I am still at the very bottom of the R learning
> curve...
> plot(hov, position=c(0,0,1,1))
> plot(loc,position=c(0,0,1,1),newpage=F)
>
> Thankful for any pointers or suggestions.
>
> Regards,
>
> Don
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Oscar Perpiñán Lamigueiro
Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
Grupo de Sistemas Fotovoltaicos (IES-UPM)
URL: http://oscarperpinan.github.io
Twitter: @oscarperpinan
More information about the R-sig-Geo
mailing list