I have point data with lat
and lng
coordinates. At each point, there is a certain value, ranging between 0 and 100. I want to plot that as a heightmap, using the rgl
package. That is an example if found here
library(rgl)
data(volcano)
z <- 2 * volcano # Exaggerate the relief
x <- 10 * (1:nrow(z)) # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z)) # 10 meter spacing (E to W)
zlim <- range(z)
zlen <- zlim[2] - zlim[1] + 1
colorlut <- terrain.colors(zlen,alpha=0) # height color lookup table
col <- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
open3d()
rgl.surface(x, y, z, color=col, alpha=0.75, back="lines")
However, I do not understand it. Its the first time I work with rgl
and do not quite understand what kind of data is supplied here (volcano
).
I had look at it but I do not understand it...
What is in 1:nrow(z)
and 1:ncol(z)
?! Why is that the spacing? What input data does the rgl.surface()
function need?
How would I use the code when my data only has three cols, lat
, lng
and a value
. I tried to replace
z <- myData$value
x <- myData$lat
y <- myData$lng
That did not work.