plot order in spplot with sp.layout
Hi,
An alternative approach is to use a custom panel function, which is even
more flexible that the solution Edzer suggested. To add polygons and
points to a grid map using a custom panel function:
spplot(grid_object, "layer_to_plot",
panel = function(...) {
panel.gridplot(...)
sp.polygons(polygon_object)
sp.points(point_object)
})
see also the R wiki article on spatial data visualization [1].
cheers,
Paul
[1]
http://rwiki.sciviews.org/doku.php?id=tips:spatial-data:spatial_data_visualization
On 05/23/2011 03:25 PM, Edzer Pebesma wrote:
On 05/23/2011 03:13 PM, Tom Gottfried wrote:
Dear list,
when doing the following, the grid is plotted on top of the sp.layout-item:
data(meuse.grid)
coordinates(meuse.grid)<- ~x+y
gridded(meuse.grid)<- TRUE
data(meuse.riv)
meuse.riv<- SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)), 1)))
spplot(meuse.grid, sp.layout=list("sp.polygons", meuse.riv))
?spplot says:
"for grids and polygons sp.layout is drawn afterwards (so the item will
not be overdrawn by the grid and/or polygon)."
Do I misunderstand the documentation or is this a bug?
Please try:
spplot(meuse.grid, sp.layout=list("sp.polygons", meuse.riv,
first = FALSE))
I added this now to the spplot documentation.
Thanks!
Tom
Paul Hiemstra, Ph.D. Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 currently @ KNMI paul.hiemstra_AT_knmi.nl