[R-sig-Geo] problem saving spplot in a loop

Alexandre VILLERS alexandre.villers at cebc.cnrs.fr
Mon Dec 7 15:09:17 CET 2009


Hey,

I wrote a loop and want to save plots of multiple 
SpatialPolygonDataFrame objects with something like

png(paste("K:/Outarde/ADrien/FigTemp/PGR",l,"_",j,".png",sep=""), 
height=1000, width=2000,res=300)
b<-spplot(grTs[,c("PGRobs04","PGRobs48")], 
col.regions=palAb(30)            
dev.off()

and

png(paste("K:/Outarde/ADrien/FigTemp/Abondance",l,"_",j,".png",sep=""), 
height=1000, width=3000,res=300)
spplot(grTs[,c("ov2000","ov2004","ov2008")], 
col.regions=palAb(17),at=cutsAb)
dev.off()

When I run "manually" the code (specifying the l and j values for the 
loop), everything is fine and I get nice png files. When the code loops 
on its own, I get blank images. I suspect this is a problem of the time 
taken by spplot to build the image in time for saving in the loop.
Is this correct and how can I properly overcome this problem ?

Best regards

Alex

-- 
Alexandre Villers
PhD Candidate
AgriPop
Centre d'Etudes Biologiques de Chizé-CNRS UPR1934
79360 Beauvoir sur Niort

Phone +33 (0)5 49 09 96 13
Fax   +33 (0)5 49 09 65 26




__________ Information from ESET Mail Security, version of virus signature database 4667 (20091207) __________

The message was checked by ESET Mail Security.
http://www.eset.com



More information about the R-sig-Geo mailing list