Viewing

Example 005




setwd("/Users/rockel/work/R/examples/example005")

#
#... Example for a quantity with flag_values and flag_menaings attributes
ncfile<-"r04_Europe_044_extpar1.5.nc"
pdffile<-"exp005.pdf"
title<-"Soil Types"
varname<-"SOILTYP"
nc <- nc_open(ncfile)
#ratio  <- length(nc$dim$lat$vals) / length(nc$dim$lon$vals)   # geographical
ratio  <- length(nc$dim$rlat$vals) / length(nc$dim$rlon$vals)  # rotated
nc_close(nc)
# decide whether landscape or portrait looks prettier
if (ratio > 1.) {
  pdf(pdffile, width=8.27,height=11.69,paper="special")
  par(oma=c(3,2,5,2))
  layout(matrix(c(1,2),2,1, byrow=T), height=c(1,lcm(2.5)),respect=T)
} else {
  pdf(pdffile, width=11.69,height=8.27,paper="special")
  par(oma=c(3,2,5,2))
  layout(matrix(c(1,2),2,1, byrow=T), height=c(1,lcm(2.5)),respect=T)
}
par(mar=c(0.5,0.8,0.5,0.8))
tmp <- plotmap(file=ncfile, varname=varname,rivers=F,cities=F,sponge=0,grid.txt=F, hires=F,map.lwd=1,interior=T)

par(mai=c(0.5,0.5,0.35,0.5))
plot_colourbar(tmp,cex.axis=0.5)
mtext(title, 3,outer=T, font=1, cex=1.4)
dev.off()
 Viewing