Hi Yihui,
Thank you so much for your help. It works using following function:
Zia

saveGIF(
for (i in 1:ns){
print(spplot(sim_ns[,i], main = list(label=paste("SIM",i),cex=1.5),
colorkey = list(space="right",height=1, width=1.5,labels=list(cex=1.5)),
par.settings=list(axis.line=list(col=NA)),at=at.pred,
col.regions=rgb.palette(100)))},
height = 600, width = 450, interval = .5, outdir = getwd())
}

On 1/25/2012 5:39 PM, Yihui Xie wrote:
> You can try the animation package with the function saveGIF(); see the
> help page for more info. Basically you just put the code in
>
> saveGIF({
>    whatever code that produces plots
> })
>
> and you do not need to take care of the issues like opening the
> graphical devices; the process is automatic.
>
> Regards,
> Yihui
> --
> Yihui Xie<xieyihui@gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Wed, Jan 25, 2012 at 3:44 PM, Zia Ahmed<zua3@cornell.edu>  wrote:
>> I am trying to create an animated GIF file from a set of PNG files
>> created from number realization.  Itried with animation ( depend -
>> ImageMagick) and caTools packages, but I did not successful to make the
>> GIS file.  Is  there any way to do this?
>> Thanks
>> Zia
>>
>> # GIF animation
>>
>> library(sp)
>> library(gstat)
>> library(lattice)
>> library(RColorBrewer)
>> library(maptools)
>> library(maps)
>> library(ggplot2)
>> library(lubridate)
>> library(animation)
>> library(fields) # for tim.colors
>> library(caTools) # for write.gif
>> library(raster)
>>
>> data(meuse)
>> data(meuse.grid)
>> coordinates(meuse)<- ~x+y
>> coordinates(meuse.grid)<- ~x+y
>> gridded(meuse.grid)<- TRUE
>>
>> lzn.vgm<- variogram(log(zinc)~1, meuse)
>> lzn.fit<- fit.variogram(lzn.vgm, model = vgm(1, "Sph", 900, 1))
>>
>> ns=4
>>
>> sim_ns = krige(log(zinc)~1, meuse, meuse.grid, model = lzn.fit,
>> nmax = 30, nsim = ns)
>>
>> # Save figures as PNG files
>>
>> rgb.palette<- colorRampPalette(c("lightyellow","green","orange","brown"),
>> space = "rgb")
>>
>> setwd("C:/sim")
>>
>> for (i in 1:ns){
>> png(filename = paste("sim",i,".png",sep=""), width=400, height=500,
>> units="px",
>> pointsize=12, bg="transparent", res=NA)
>> print(spplot(sim_ns[,i], main = list(label=paste("SIS",i),cex=1.5),
>> par.settings=list(axis.line=list(col=NA)),
>> col.regions=rgb.palette(22)))
>> dev.off()
>> }
>>
>> # Creat a gif.file
>> system("convert -delay 40 *.png sim.gif") #
>> Source(http://ryouready.wordpress.com/2010/11/21/animate-gif-images-in-r-imagemagick/)
>> Invalid Parameter - 40
>> Warning message:
>> running command 'convert -delay 40 sim*.png plot.gif', invisible = F,
>> wait=T' had status 4
>>
>>
>>
>> ---------------------
>> Zia Ahmed, PhD
>> Research Associate
>> Department of Crop and Soil Sciences
>> 1002 Bradfield Hall, Cornell University
>> Ithaca, NY 14853-4203
>> t. 607.255.9387
>> f. 607.255.3207
>> email zua3@cornell.edu
>>
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
---------------------
Zia Ahmed, PhD
Research Associate
Department of Crop and Soil Sciences
1002 Bradfield Hall, Cornell University
Ithaca, NY 14853-4203
t. 607.255.9387
f. 607.255.3207
email zua3@cornell.edu



	[[alternative HTML version deleted]]

