[R-sig-Geo] Marginless plot output for georegistration of output graphics

Roger Bivand Roger.Bivand at nhh.no
Wed Jan 17 19:44:18 CET 2007


On Wed, 17 Jan 2007, David Forrest wrote:

> On Wed, 17 Jan 2007, David Forrest wrote:
> 
> > On Wed, 17 Jan 2007, Roger Bivand wrote:
> ...
> > I feel really close with this, except for the key.
> 
> Answering my own question by looking through the source at 
> http://r-spatial.cvs.sourceforge.net/r-spatial/sp/R/spplot.R?view=markup I 
> see that spplot uses levelplot for many of its plots and will then accept 
> a colorkey=FALSE argument to inhibit the keys.  So, for everything but 
> SpatialPointsDataFrames, maybe something like this would work:
> 
> library(maptools)
> xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
> IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
> 
> xx.p<-spplot(xx,'AREA',
>         par.settings=theme.novpadding, # lattice theme from prior
>         scales=list(axs='i',draw=FALSE),
>         xlim=bbox(xx)[1,],ylim=bbox(xx)[2,],colorkey=FALSE)
> 
> mywidth<-myheight<-600
> if(mapasp(xx)>1)  mywidth  <-myheight / mapasp(xx)
> if(mapasp(xx)<1)  myheight <-mywidth  * mapasp(xx)
> tf2<-tempfile()
> png(file=tf2,width=mywidth,height=myheight,bg='transparent')
> print(xx.p)
> dev.off()
> system(paste("display", tf2))
> 
> 
> What do I need to to do turn the key off for spplot(SpatialPointsData) ?

I can't see it, I thought it might be auto.ket=FALSE, but it doesn't seem 
to be that. To be honest, I would feel more comfortable with base 
graphics and setting my own class intervals and colours. Lattice graphics 
seem more worth the trouble when conditioning, which isn't the case here. 
The aspect doesn't seem happy yet, and for NA and projected CRS, you get 
"iso" back instead of the aspect from mapasp.

Roger



> 
> Dave
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list