With the recently relased version of the package RGL (V. 0.92.879) there is a new option to publish 3D plots as an interactive WebGL graphic.
Nearly every 3D plot you set up in a RGL window can be exportet via a very easy command. Just plot as usual into your rgl device and then use the command “writeWebGL()”.

Click to open the TimeSpace Cube WebGL Plot

Time Space Cube sample:

Dependable on your hardware and software specifications (graphics have to support a newer OpenGL version) you’ll be able to open my try in your browser window:

Click here to open my WebGL sample in a new window (~3MB)

Here the command to export your RGL window to a webpage:

browseURL(paste(“file://”, writeWebGL(dir=file.path(tempdir(), “webGL”), width=700), sep=””))

Advertisements

Hägerstrand time-space cube with R

 

With the rgl package it’s possible to interact with the 3d visualization of the timespace tracks.

Code example:
plot3d(lon,lat,timedate, xlim=range(lon), ylim=range(lat), zlim=range(timedate), ticktype=”detailed”, xlab=”longitude”, ylab=”latitude”, zlab=”Date”, col= as.POSIXlt(daten[,”Date”])$mday, type=”l”, main=plottitle)

In the posted example individual waypoints were added by drawing vertical lines.

Many asked for the code. Here is some of it:

################################################# # 2.5 PLOT HŠgerstrand TimeSpace 3d interaktiv ################################################# dimen <- dim(daten) dts = daten$Date tms = daten$Time timedate <- timeDate(paste(dts, tms), format = “%Y-%m-%d %H:%M:%S”, zone = “GMT”, FinCenter = “Europe/Berlin”) # timeDate Object erzeugen zshift = 180000 plottitle <- paste(proband, “TimeSpaceCube vom”, range(dts)[1], “bis”, range(dts)[2]) plot3d(lon,lat,as.numeric(timedate+zshift), xlim=range(lon), ylim=range(lat), lit=TRUE, box=FALSE, smooth=TRUE, alpha=c(1), zlim=as.numeric(range(timedate)+zshift), lwd=”3″, axes=T, xlab=””, ylab=””, zlab=””, fog=TRUE, col= as.POSIXlt(daten[,”Date”])$mday%%2+1, type = “l”) # Plot HŠgerstrand timespace path / x=longitude , main=plottitle light3d(theta = 0, phi = 15) rgl.bg( sphere = FALSE, fogtype = “none”, color=c(“#FFFFFF”,”white”), back=”lines”) #plot3d(daten_wp$Longitude[6],daten_wp$Latitude[6], timedate[1], size=400, type=”p”) #grid3d(“z+”, at = NULL, col = “#888888″, lwd = 1, lty = 2, n = 8) plot3d(range(lon)[2],lat, timedate, xlim=range(lon), ylim=range(lat), zlim=range(timedate),col=”#CCCCCC”, lwd=”1″, add=T, type=”l”) #sideplot plot3d(lon,lat, range(timedate)[1], xlim=range(lon), ylim=range(lat), zlim=range(timedate),col=”#CCCCCC”, lwd=”1″, add=T, type=”l”) # GroundedPlot #grid3d(“z”, at = NULL, col = “#CCCCCC”, lwd = 1, lty = 2, n = 4) plot3d(daten_wp$Longitude,daten_wp$Latitude, timedate[1]+300, col=”darkgrey”, size=”5″, lwd=”3″, type=”p”, add=T) #plot3d(daten_wp$Longitude,daten_wp$Latitude, range(timedate)[2], col=”darkgrey”, size=”5″, lwd=”3″, type=”p”, add=T) rgl.texts(daten_wp$Longitude,daten_wp$Latitude,range(timedate)[2], color=”black”, text=daten_wp$wpOpen, adj = 0.5, family = “sans”, font = 1, cex = 1, useFreeType=F) daten_wp$id <- c(1:dim(daten_wp)[1]) for(ii in unique(daten_wp[,”id”])){ if (daten_wp$isConstraint[ii] == “TRUE”) { line1 <- c(daten_wp$Longitude[ii], daten_wp$Latitude[ii], as.numeric(timedate[1])[1]) line2 <- c(daten_wp$Longitude[ii], daten_wp$Latitude[ii], as.numeric(range(timedate)[2]+zshift)[1]) lineall <- rbind(line1,line2) lines3d(lineall, lwd=300, col=”black”, alpha=c(0.1)) } } aspect3d(1,1,1.5) # Jeder Proband unterschiedliche Werte zur Anonymisierung snapshot3d(paste(plotpath, proband, “_timespacecube.png”, sep=””)) for (i in 1:60) { count <- seq(1,90,1)[i] rgl.viewpoint(theta=0, phi=count) filename <- paste(plotpath, “\\timespaceani\\pic”,formatC(i,digits=1,flag=”0″),”.png”,sep=””) rgl.snapshot(filename) }

%d bloggers like this: