[R-sig-Geo] Question with spplot for publication

Roger Bivand Roger.Bivand at nhh.no
Fri Aug 22 09:38:21 CEST 2014


On Fri, 22 Aug 2014, Ziyu Ma wrote:

> Dear all,
>
> I miss you guys from GEOSTAT Bergen!
>
> Here's my question: I want to make a map directly from R for my manuscript,
> using a raster layer overlaid with spatial polygons as outlines.

Typically, you use the sp.layout= argument to spplot. This takes a list of 
extra information to be plotted. However, spatial polygons are thought of 
as filled, so you should coerce then to SpatialLines first:

spl <- list("sp.lines", as(my_polys, "SpatialLines"), lwd=2, col="white")

then

spplot(..., sp.layout=spl)

or a list of lists if there are other kinds of information to add.

Hope this helps,

Roger

>
> Please see the attachment for what I mean: http://1drv.ms/1sYYqPg
>
> I did the upper plot in the attachement using these codes:
>
> NRI = stack(NRI.A,NRI.G)  # NRI.A and NRI.G are raster layer names
> names(NRI) = c("Angiosperms NRI", "Gymnosperms NRI")
> spplot(NRI)
>
>
> I need to put two rasters together in spplot because I want to use the same
> legend scale.
>
> I also want to add the outlines, so that it can look like the Photoshopped
> plot in the attachment.
>
> Normally, if not using spplot, I can do this:
>
> plot(NRI.G) # NRI.G is a raster layer
> plot(Outlines)  # Outlines is a SpatialPolygons object
>
>
> But how can I do it for both panels in spplot? I think the panels and
> titles in spplot are very neat, so it is preferred if there is a straight
> forward way to tweak the settings.
>
> Or should I use other functions than spplot? (e.g. try coding the color
> scheme of the 2 plots and place them side by side?)
>
> Thank you for the help. I really appreciate those who made R able to
> produce publication quality plots.
>
> Cheers,
> Ma​
>
> Ziyu Ma
> PhD Student
> Ecoinformatics & Biodiversity,
> Department of Bioscience, Aarhus University
> Ny Munkegade 114, DK-8000 Aarhus C, Denmark
>
> 	[[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

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list