[R-sig-Geo] question about image function

Hodgess, Erin HodgessE at uhd.edu
Tue Mar 5 22:33:29 CET 2013


That was it...thanks so much!

________________________________________
From: Clint Bowman [clint at ecy.wa.gov]
Sent: Tuesday, March 05, 2013 2:46 PM
To: Michael Sumner
Cc: Hodgess, Erin; r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] question about image function

When using png in a loop, especially one where the loop index is an
integer, I usually make use of the "%02d" in the file name, e.g.,
png("pred_%02d_a.png",...)

Clint Bowman                    INTERNET:       clint at ecy.wa.gov
Air Quality Modeler             INTERNET:       clint at math.utah.edu
Department of Ecology           VOICE:          (360) 407-6815
PO Box 47600                    FAX:            (360) 407-7534
Olympia, WA 98504-7600

         USPS:           PO Box 47600, Olympia, WA 98504-7600
         Parcels:        300 Desmond Drive, Lacey, WA 98503-1274

On Wed, 6 Mar 2013, Michael Sumner wrote:

> I don't see filename defined, or any packages required. Is it the png files
> that are a problem or the 'kmlsetup' output? (whatever that is)
>
> See the animation package for extremely simplifed image frame creation btw
>
> On Wednesday, March 6, 2013, Hodgess, Erin wrote:
>
>> Hello again!
>>
>> I'm running into a problem with the image function within a loop.  When I
>> put it to the screen, it works fine, but when I put it to a PNG file, the
>> picture doesn't change.
>>
>> Here is the code:
>>
>> for(i in 1:11) {
>> j1 <- (i-1)*n2 + 1
>> j2 <- i*n2
>>
>>  predx <- data.frame(pred=kr3$var1.pred[j1:j2],lon=kr3 at sp
>> @coords[,1],lat=kr3 at sp@coords[,2])
>>
>>  coordinates(predx) <- ~lon+lat
>>  proj4string(predx) <- proj4string(kr3)
>>  predx.wgs84 <- spTransform(predx,CRS("+proj=longlat +datum=WGS84"))
>>  llSPix <- as(llSGDF, "SpatialPixelsDataFrame")
>>  (st <- system.time(llSPix$pred <- idw(pred ~ 1,
>>  loc=predx.wgs84,newdata = llSPix, nmax = 16)$var1.pred))
>>  cat("stuff",i,"\n")
>> f1 <- paste("pred",i,"a.png",sep="")
>> #Works fine
>> image(llSPix,"pred",col=bpy.colors(),main=f1)
>>
>>
>>  assign("file1",f1)
>>  cat("filen",file1,"\n")
>>  png(filename = file1, width = GRD.wgs84$width,
>>  height = GRD.wgs84$height,bg="transparent")
>>  par(mar = c(0, 0, 0, 0), xaxs = "i", yaxs = "i")
>>  image(llSPix, "pred", col = bpy.colors())
>>  dev.off()
>>  kmlsetup(obj = GRD.wgs84, kmlfile =filename,
>>  imagefile = file1, name =as.character(2000+i))
>>
>> }
>>
>> Has anyone run into this before, please?
>>
>> Thanks,
>> Erin
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org <javascript:;>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
> --
> Michael Sumner
> Hobart, Australia
> e-mail: mdsumner at gmail.com
>
>       [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list