[R-sig-Geo] symbols in spplot

Peter van Horssen p.w.van.horssen at buwa.nl
Wed Feb 4 11:21:36 CET 2009


Dear all,

I have a plot problem which is related to the 'contourlines on a plot  
question' from a while ago.

I have a  map with 144 polygons (squares), for each square we calculate 
the mean flight direction (of birds).
What I try to plot is a map with the samplesize as a
greyscale in the polgons and an arrow on top depicting the mean 
direction of that square.
The polygonmap with greyscale is easily plotted with spplot.
The arrows with mean direction are a bit more difficult. Most sources
point towards the 'grid' package or towards arrows(). Both draw arrows
with xy pairs (form > to) in graph coordinates.
However 'mysymbols' in the library TeachingDemos plots a arrow symbol
with a direction 'dir' (in radians) and a fixed length, just what I need.
Unfortunately these arrows only plot with 'plot' command (see attached 
code) and therefore do not allign
with the plot resulting from ssplot. As you can see  the arrows are 
plotted  as a pch 'symbol'.

I tried to construct a 'sp.points' element for the sp.layout
with the my.symbols ( .....) argument but this doesn't work
The arrow.sp$pch is NULL and when I manually force the my.symbol(..) in 
it by :
####
arrow.sp$pch <- 
my.symbols(raster.midpoint$raster.mid.x1,raster.midpoint$raster.mid.x2,ms.arrows, 
angle= Data$rad, inches=0.5, adj=0.5, lwd=1.5, code = 2, col = 'blue')
####
the spplot command generates an error

Question:
is there an obvious solution tot this (relative simple) problem ?
if not, is there a way to 'allign' de plots from spplot and plot (the 
arrowplot) ?



thanks in advance


##plot raster##
radarcirkels.sp <- list("sp.polygons", radarcirkels)
circle2.sp <- list("sp.polygons", circle2, add= TRUE)
turbines.sp <- list("sp.points", turbines, pch=18, add= TRUE, col = red')
metmast.sp <- list("sp.points", metmast, pch = 19, col = 'red', add= TRUE)
turbine.radar.layout <- list(radarcirkels.sp, circle2.sp, turbines.sp, 
metmast.sp)
colors <- shadepalette("darkgreen","white",n=20)
spplot (raster1["n"],col.regions=colors,at=c(0,10,50,100,200,300), 
sp.layout = turbine.radar.layout)

##plot arrows ##
library(TeachingDemos)
plot(raster)
plot(radarcirkels, add=TRUE)
plot(circle2, add= TRUE)
plot(turbines, pch=18, add= TRUE, col = 'red')
plot(metmast, pch = 19, col = 'blue', add= TRUE)
plot(raster,pch=my.symbols(raster.midpoint$raster.mid.x1,raster.midpoint$raster.mid.x2, 

      ms.arrows, angle= Data$rad, inches=0.5, adj=0.5, lwd=1.5, code = 
2, col = 'blue'), add=TRUE)

-- 
================================
Peter van Horssen
Bureau Waardenburg bv
Adviseurs voor ecologie & milieu
Postbus 365
4100 AJ Culemborg
Tel: 0345-512710
Fax: 0345-519849
e-mail: p.w.van.horssen at buwa.nl
================================

---------------------------- DISCLAIMER -------------------------- 
De informatie verzonden met dit e-mail bericht is uitsluitend bestemd voor de geadresseerde. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking aan derden is niet toegestaan. Gebruik van deze informatie door anderen dan de geadresseerde is verboden. U wordt verzocht bij onjuiste adressering de afzender direct te informeren door het bericht te retourneren.




More information about the R-sig-Geo mailing list