[R-sig-Geo] spplot for raster not drawn
Oscar Perpiñan Lamigueiro
oscar.perpinan at upm.es
Tue Sep 13 13:01:30 CEST 2011
Hi,
Another approach is to use the layout argument of levelplot.
As an example, I use the data from Cressie and Wikle, following the
superb Edzer Pebesma's notes in demo/CressieWikle.R in the
spacetime package.
Best,
Oscar.
library(raster)
library(rasterVis)
library(zoo)
url <- "ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data/"
sst.dat = read.table(paste(url, "SST011970_032003.dat", sep=''), header
= FALSE)
sst.ll = read.table(paste(url, "SSTlonlat.dat", sep=''),
header = FALSE)
sp <- SpatialPointsDataFrame(sst.ll, sst.dat)
gridded(sp) <- TRUE
proj4string(sp) = "+proj=longlat +datum=WGS84"
s <- brick(sp)
idx <- seq(as.Date('1970-01-01'), as.Date('2003-03-01'), by='month')
idx <- as.yearmon(idx)
s <- setZ(s, idx)
layerNames(s) <- as.character(idx)
##One year per page with layout=c(3,4)
trellis.device('pdf', file='cressie_level.pdf')
levelplot(s, layout=c(3, 4))
dev.off()
## layout inside histogram works correctly
## only with rasterVis 0.10-5 (at R-Forge)
trellis.device('pdf', file='cressie_hist.pdf')
histogram(s, layout=c(3, 4))
dev.off()
-------------------
Oscar Perpiñán Lamigueiro
Dpto. Ingeniería Eléctrica
EUITI-UPM
http://procomun.wordpress.com
-----------------------------------------
> Use print on your levelplot command. This is in the R FAQ (7.22).
>
>Paul
>
>On 09/13/2011 09:10 AM, Els Ducheyne wrote:
>> dear list
>> I want to display a time series of data using either spplot or
>> levelplot to verify consistency in the raw images prior to
>> processing (visual quality check) to do this I am use spplot (or
>> levelplot). This works up to 16 images, however if I want to see
>> more I have to split the inputfiles and put them in a loop. When
>> the loop is executed, I can see the quartz window but the content is
>> not shown. Does anyone have an idea how to solve this ? See below
>> for information on OS and versions + code
>>
>> Thanks for help
>> Els
>>
>>
>> require(raster) #raster package = 1.9-5
>> require(rasterVis) #rasterVis = 0.10-4
>> setwd(outputdir)
>> #get all the inputdata
>> par(ask=T)
>> inputlist <- list.files(pattern="LSTDay")
>> datadisplay <- seq(1,length(inputlist),16)
>> datadisplay <- c(datadisplay,length(inputlist))
>> n <- length(datadisplay)-1
>> for (i in 1:n){
>> input <- inputlist[datadisplay[i]:datadisplay[i+1]-1]
>> images <- stack(inputlist)
>> NAvalue(images)<-0
>> #spplot(images,col.regions=terrain.colors(80)) # quartz is
>> shown but remains empty
>> levelplot(images,col.regions=terrain.colors(80)) # quartz is shown
>> but remains empty hist(images,xlim=c(220*50,340*50),n=20)
>> #histograms are displayed in quartz }
>>
>>
>> $platform
>> [1] "i386-apple-darwin9.8.0"
>>
>> $arch
>> [1] "i386"
>>
>> $os
>> [1] "darwin9.8.0"
>>
>> $system
>> [1] "i386, darwin9.8.0"
>>
>> $status
>> [1] ""
>>
>> $major
>> [1] "2"
>>
>> $minor
>> [1] "13.1"
>>
>> $year
>> [1] "2011"
>>
>> $month
>> [1] "07"
>>
>> $day
>> [1] "08"
>>
>> $`svn rev`
>> [1] "56322"
>>
>> $language
>> [1] "R"
>>
>> $version.string
>> [1] "R version 2.13.1 (2011-07-08)"
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>--
>Paul Hiemstra, Ph.D.
>Global Climate Division
>Royal Netherlands Meteorological Institute (KNMI)
>Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>P.O. Box 201 | 3730 AE | De Bilt
>tel: +31 30 2206 494
>
>http://intamap.geo.uu.nl/~paul
>http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
More information about the R-sig-Geo
mailing list