[R] add=TRUE or similar in spplot?

infochat at gmx.net infochat at gmx.net
Fri Oct 21 14:30:29 CEST 2011


Dear Helper,

I have a spatial lines data frame object 'spRiverDf'. The data frame consists of numbers {0,1,...,5}. And I have a vector 'colorS' of length 6 with different colours.

If I make a plot with spplot I get a plot of the lines - colours depending on there number in the data frame column:

spplot(spRiverDf['data.col.1'], zcol=..., names.attr=..., col.regions=colorS, lwd=10) # (A)

My problem:
- I'd like to overlay narrow lines (lwd=5) with the appropriate colors of a second data column.

My tests:
1) I tried it with the spplot options: lwd=10, sp.layout=list(list(spRiverDf['data.col.2'], col=colorS, lwd=5))
2) Second try: result <- spplot("entries_see_(A)"); result + layer(sp.lines(spRiverDf['data.col.2'], col=colorS, lwd=5))

My results:
- In both tests I get with spplot the desired but with the additional things only single-coloured (takes the first entry of 'colorS') lines.

My questions:
- Is there a possebility to overlay two spplots? Something like option add=TRUE for the usual 'plot' command.
- Or is there an easy way to select desired lines of a spatial plot data frame (e.g. with a special colour) that I can use 'sp.layout' or 'layer'?
- Of course I can create for additional data frame columns own spatial lines data frames for each color (depending on the number entry in the column) but this is very time-consuming - and realy not elegant.

Thank you for your help!
Thomas
--



More information about the R-help mailing list