Ok thanks. thats cool.

The brick I was animating was a  3 degree lat lon with about 2000 layers.
so I would have to stick with animate.

On Mon, Nov 29, 2010 at 3:12 PM, Jacob van Etten <jacobvanetten@yahoo.com>wrote:

> So just for the record, what follows is one way of creating an animation
> from multiple rasters, using caTools.
> The trick is to create an array and fill it with your raster layers.
> It requires you to have your whole array in RAM before you start to write.
> This is a difference with package animate, which seems to "append" each
> raster to the gif movie.
>
> library(raster)
> library(caTools)
> setwd("c:/")
>
>
> logo <- raster(system.file("external/rlogo.grd", package="raster"),
> values=TRUE)
> logoA <- array(0, c(77, 101, 255))
> for(i in 1:255)
> {
>     logoM <- getValues(logo, format="matrix")
>     logoM[logoM<i] <- 0
>     logoA[,,i] <- logoM
> }
> write.gif(logoA, "disappearingRlogo.gif", col="rainbow", delay=1)
>
> Jacob.
>
> --- On *Mon, 29/11/10, steven mosher <moshersteven@gmail.com>* wrote:
>
>
> From: steven mosher <moshersteven@gmail.com>
>
> Subject: Re: [R-sig-Geo] Anyone attempted to "animate" multi-layered
> rasters?
> To: "Yihui Xie" <xie@yihui.name>
> Cc: "Jacob van Etten" <jacobvanetten@yahoo.com>, "Kevin Ummel" <
> kevinummel@gmail.com>, "R-sig-Geo" <R-sig-Geo@stat.math.ethz.ch>
> Date: Monday, 29 November, 2010, 23:27
>
>
> Inlined
>
> On Mon, Nov 29, 2010 at 1:36 PM, Yihui Xie <xie@yihui.name<http://mc/compose?to=xie@yihui.name>
> > wrote:
>
> I have solved the second problem a couple of weeks ago but did not
> release it to CRAN; recently I'm in the process of moving my
> repository to GitHub: https://github.com/yihui/animation I have
> finished it yesterday. If the namespace conflict is a serious problem,
> I can push a new version to CRAN soon.
>
>
>  It's not a serious problem, just an annoyance. In my work I just load
> animation first and then raster second. But if others are not careful and
> load animation second they may not see that
> MASS  function *area*  clobbers  raster *area*. I thought I had taken crazy
> pills when my raster code stopped working and the error code would not have
> been easily figured out.
>
>
>
> For the first problem, I am not aware of the potential problems, but I
> will try to remove these setwd() calls in the next version. I do not
> even remember why I needed to change working directories frequently 3
> years ago when I wrote these functions... I guess I forgot to add
> these comments to my code then:
>
>
> Dont worry I did the same thing in some of my code before I learned a big
> lesson.
> you, used setwd() when you wanted to write the image files to the image
> directory
> and then you returned to the current dir on exit ( as I recall)
>
>
>
>
> ## When I wrote this, only God and I understood what I was doing
> ## Now, God only knows
>
>
> Actually the code was pretty easy to figure out and it taught me some
> things I didnt know
> I very much enjoyed messing around with it
>
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui@gmail.com <http://mc/compose?to=xieyihui@gmail.com>>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Mon, Nov 29, 2010 at 3:06 PM, steven mosher <moshersteven@gmail.com<http://mc/compose?to=moshersteven@gmail.com>>
> wrote:
> > I think GraphicsMagick is superior.  I have not programmed C since maybe
> > 1993, so I am read capable and write limited. I've got the source. It
> does
> > not look easy.
> > For sci-vis ( scientific visualization) I am wondering what the best
> format
> > will be for animation.
> >
> > A couple other notes. It would be nice if animation were modified  a bit.
> > 1. To rewrite the functions so that the api does not change directories
> when
> > doing the
> >      image writing. As it stands now the code changes directories to the
> > IMAGE directory
> >      writes images and then changes back ( If I am recalling) This led to
> > some problems
> >      with raster. I think Robert Hijmans fixed that problem on the raster
> > side, but I would
> >      suggest changing it on the animation side as well.
> >  2. package dependencies. The package loads the MASS package which has a
> > namespace
> >     fight with api in raster  ( area). while this is easily fixed, it did
> > cost me a couple days to figure out.   In short, your example code
> requires
> > certain packages to be loaded, but for those
> >     folks who just want to use ani.options, ani.start() and ani.stop(),
> the
> > packages are not required.
> >  I just solved those two problems by hacking up the nice package, and
> really
> > tuning it to my purpose.  in my perfect world  it would work like this
> and
> > just be a method one uses on a
> > raster "brick" object.
> > animate(brick, imageDirectory="tbd", type=c("html","mov" etc....),...)
> >
> > conceptually..
> >
> >
> >
> > On Mon, Nov 29, 2010 at 12:43 PM, Yihui Xie <xie@yihui.name<http://mc/compose?to=xie@yihui.name>>
> wrote:
> >>
> >> Porting ImageMagick or GraphicsMagick into R is not a trivial task,
> >> and my knowledge on C is rather limited. I will be very happy if
> >> anyone can do this.
> >>
> >> And thanks Steven for letting me know GraphicsMagick. It looks like a
> >> better choice.
> >>
> >> Regards,
> >> Yihui
> >> --
> >> Yihui Xie <xieyihui@gmail.com <http://mc/compose?to=xieyihui@gmail.com>
> >
> >> Phone: 515-294-2465 Web: http://yihui.name
> >> Department of Statistics, Iowa State University
> >> 2215 Snedecor Hall, Ames, IA
> >>
> >>
> >> On Mon, Nov 15, 2010 at 4:49 PM, Jacob van Etten
> >> <jacobvanetten@yahoo.com <http://mc/compose?to=jacobvanetten@yahoo.com>>
> wrote:
> >> >
> >> > I got ImageMagick working on Windows. The only problem occurred when I
> >> > tried to write the movie file to a directory with subdirectories in
> it. It
> >> > works with an empty directory, though.
> >> >
> >> > I think it should be possible to incorporate the code from ImageMagick
> >> > or GraphicsMagic into an R package, making an external install
> unnecessary.
> >> >
> >> > Jacob.
> >> >
> >> > --- On Mon, 15/11/10, Kevin Ummel <kevinummel@gmail.com<http://mc/compose?to=kevinummel@gmail.com>>
> wrote:
> >> >
> >> > From: Kevin Ummel <kevinummel@gmail.com<http://mc/compose?to=kevinummel@gmail.com>
> >
> >> > Subject: Re: [R-sig-Geo] Anyone attempted to "animate" multi-layered
> >> > rasters?
> >> > To: "steven mosher" <moshersteven@gmail.com<http://mc/compose?to=moshersteven@gmail.com>
> >
> >> > Cc: "Jacob van Etten" <jacobvanetten@yahoo.com<http://mc/compose?to=jacobvanetten@yahoo.com>
> >,
> >> > R-sig-Geo@stat.math.ethz.ch<http://mc/compose?to=R-sig-Geo@stat.math.ethz.ch>,
> xie@yihui.name <http://mc/compose?to=xie@yihui.name>
> >> > Date: Monday, 15 November, 2010, 23:26
> >> >
> >> > Thanks, Jacob.
> >> > For the community: I've successfully installed ImageMagick on Mac OS
> >> > 10.6.4 (i.e. the sample commands to verify functionality check
> >> > OK:
> http://www.imagemagick.org/script/binary-releases.php?ImageMagick=cmdb7qc5snnquootuef90ki645#macosx
> ).
> >> > I receive an error running Jacob's example code:
> >> > Error in cmd.fun(sprintf("%s --version", convert), intern = TRUE) :
> >> >   error in running command
> >> > sh: convert: command not found
> >> > I don't believe this is an 'animate' issue, but is a thorny path
> problem
> >> > that apparently plagues ImageMagick installs via MacPorts. I tried
> some
> >> > things based on the message boards at ImageMagick without success.
> This
> >> > isn't the place for ImageMagick troubleshooting, but a heads up for
> Mac
> >> > users trying to implement Jacob's example...
> >> > Thanks,
> >> > Kevin
> >> > On Nov 15, 2010, at 9:35 PM, steven mosher wrote:
> >> >
> >> > Thanks Jacob,
> >> >
> >> >  I was unable to get ImageMagick working ( which saveMovie() relies
> >> > upon.. as I recall ) so I had to live with the html animation.
> >> >
> >> >
> >> >
> >> > On Mon, Nov 15, 2010 at 12:58 PM, Jacob van Etten
> >> > <jacobvanetten@yahoo.com<http://mc/compose?to=jacobvanetten@yahoo.com>>
> wrote:
> >> >
> >> > A function is not really necessary. It´s actually quite simple.
> >> >
> >> > library(raster)
> >> > library(animation)
> >> > setwd("c:/empty")
> >> >
> >> > logo <- raster(system.file("external/rlogo.grd", package="raster"),
> >> > values=TRUE)
> >> >
> >> > saveMovie(
> >> > for(i in 1:250)
> >> > {
> >> >     logo1 <- logo
> >> >     logo1[logo1<i] <- 0
> >> >     #here you could also extract a RasterLayer from a RasterStack
> >> >     plot(logo1, main=i)
> >> > },
> >> > loop=1,
> >> > interval= 0.1,
> >> > outdir = getwd(),
> >> > moviename="logo")
> >> >
> >> > Cheers,
> >> >
> >> > Jacob.
> >> >
> >> > --- On Sat, 13/11/10, Kevin Ummel <kevinummel@gmail.com<http://mc/compose?to=kevinummel@gmail.com>>
> wrote:
> >> >
> >> > From: Kevin Ummel <kevinummel@gmail.com<http://mc/compose?to=kevinummel@gmail.com>
> >
> >> > Subject: [R-sig-Geo] Anyone attempted to "animate" multi-layered
> >> > rasters?
> >> > To: R-sig-Geo@stat.math.ethz.ch<http://mc/compose?to=R-sig-Geo@stat.math.ethz.ch>
> >> > Date: Saturday, 13 November, 2010, 12:58
> >> >
> >> > Hello,
> >> >
> >> > I came across the 'animate' package, and I'm wondering if anyone has
> >> > successfully adapted it to create animations of multi-layered spatial
> data.
> >> >
> >> > This seems like a logical advance of R's spatial data visualization,
> >> > especially given the prominence of NetCDF and HDR file types, but I
> don't
> >> > want to replicate if someone else already has a function in working
> order...
> >> >
> >> > Cheers,
> >> > Kevin
> >> >
> >> > Kevin Ummel
> >> > Senior Visiting Associate, Center for Global Development
> >> > MESPOM Candidate, University of Manchester
> >> >
> >> > _______________________________________________
> >> > R-sig-Geo mailing list
> >> > R-sig-Geo@stat.math.ethz.ch<http://mc/compose?to=R-sig-Geo@stat.math.ethz.ch>
> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >> >
> >> >
> >> >
> >> >
> >> >        [[alternative HTML version deleted]]
> >> >
> >> >
> >> > _______________________________________________
> >> > R-sig-Geo mailing list
> >> > R-sig-Geo@stat.math.ethz.ch<http://mc/compose?to=R-sig-Geo@stat.math.ethz.ch>
> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >> >
> >> >
> >> >
> >> >
> >
> >
>
>
>
>

	[[alternative HTML version deleted]]

