[R] [lattice] how to overlay a geographical map on a levelplot?
Pascal Oettli
kridox at ymail.com
Wed Nov 21 05:02:57 CET 2012
Hello,
Your image is projected, not your panels.
Does it match what you are looking for?
wld <- map('world', xlim=c(west.lon.deg,east.lon.deg),
ylim=c(south.lat.deg,north.lat.deg),plot=FALSE)
wld <- data.frame(lon=wld$x, lat=wld$y)
state <- map('state', xlim=c(west.lon.deg,east.lon.deg),
ylim=c(south.lat.deg,north.lat.deg),plot=FALSE)
state <- data.frame(lon=state$x, lat=state$y)
sigdigs=3 # significant digits
# plot "appropriately" for atmospheric data: use
# * lattice::levelplot
# * one column, since atmospheric levels stack vertically
levelplot(
concentration ~ longitude * latitude | level,
data=data.3d.df, layout=c(1,n.lev),
levs=as.character(round(data.3d.df[['level']], 1)),
strip=FALSE,
strip.left=strip.custom(
factor.levels= # thanks, David Winsemius
as.character(signif(unique(data.3d.df[['level']]), sigdigs)),
strip.levels=TRUE,
horizontal=TRUE,
strip.names=FALSE,
# gotta shrink strip text size to fit strip width:
# more on that separately
par.strip.text=list(cex=0.5)
)
) +
xyplot(lat ~ lon, state, type='l', lty=1, lwd=0.5, col='black') +
xyplot(lat ~ lon, wld, type='l', lty=1, lwd=1, col='black')
Regards,
Pascal
Le 21/11/2012 08:40, Tom Roche a écrit :
>
> r-help lattice adepts:
>
> I have a question which is somewhat geospatial, so I posted to r-sig-geo
> rather than here:
>
> https://stat.ethz.ch/pipermail/r-sig-geo/2012-November/016757.html
>> summary: How to overlay a geographical map on each panel in a lattice
>> (or Trellis), e.g., of levelplot's? Note I am not inquiring about
>> creating choropleth maps[,]
>
> which Sarkar 2008 covers quite well (and which is supported by
> latticeExtra::mapplot): I just want to appropriately overlay a
> garden-variety boundary-line map on panel viewspaces defined by
> longitude and latitude.
>
> A relatively small, quite self-contained example follows the quote
> above, in which I plot toy data in the sort of lattice layout I need ...
> except that each panel lacks a map appropriate to the spatial domain. If
> your competencies extend to that, your assistance would be appreciated.
>
> TIA, Tom Roche <Tom_Roche at pobox.com>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list