Another use for a 3d view

beam.gif

One element of the local climate that we are interested in is the effect of dry season insolation on vegetation patterns. This might be particularly important in areas of dry forest. Slopes that face south receive much more direct beam radiation during the dry winter months under clear skies than north facing slopes. This can be quantified using r.sun in GRASS. The following R code uses layers moved from GRASS to produce an animation in R. The previous function 3dview is needed to run the code that is available in one file here beam.doc

library(lattice)
library(sp)
library(rgl)

urlstring<-“ftp://anonymous@200.23.34.16/simulacion/Datos”

a<-paste(urlstring,”tablon”,sep=”/”)
load(url(a))

view.3d(grid=d,dem=1,drape=1,pal=terrain.colors(100),exag=1) #Get the viewpoint right

#Now run the loop


for (i in 2:13){

view.3d(grid=d,dem=1,drape=i,pal=terrain.colors(100),exag=1)
rgl.bringtotop()
j<-as.character(sprintf(“%03.0f”, i))
j<-paste(“beam”,j,”.png”,sep=””)
rgl.snapshot(j)
}

#With image magick in Linux this then makes the animated gif

system(“convert -geometry 500 -delay 200 -loop 0 *.png beam.gif”)

The results can also be exported to Google Earth as an overlay using the function in maptools, or a version of it that I will include in another post. The kml overlay can be obtained here. Extract the contents of the zipped file to a single directory.

beam.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s