[R] overlaying a levelplot on a map plot

Simon Goodman s.j.goodman at leeds.ac.uk
Thu Apr 22 22:16:50 CEST 2010


Thanks for those pointers.... making some progress now

The following will put the levelplot on to the map, but the not with the
co-ordinates aligned...
The level plot appears on a slightly larger scale compared to the underlying
map.

In both the map and levelplot, the coordinates are in lon, lat decimal
degrees.
Hopefully I'm nearly there, with 1 or 2 tweaks. 


library(gridBase)
mlat<-c(n1,n2)
mlon<-c(n3,n4)
map('worldHires', xlim = range(mlon), ylim = range(mlat))
axis(1);axis(2);axis(3);axis(4)

lvl.plot<-levelplot(z~x+y,xyz,pretty=TRUE,at=at,col.regions=cl)
vps <- baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)
pushViewport(viewport(print(lvl.plot, newpage=FALSE)))
popViewport()
popViewport(3)

However after the line 'pushViewport(viewport(print(lvl.plot,
newpage=FALSE)))' an error is returned:

Error in unit(x, default.units) : 
  (list) object cannot be coerced to type 'double'







-- 
View this message in context: http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2021128.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list