I have created a 3d map using rgl.surface(), mainly following Shane's answer in this post. Using my own data, I get this map

enter image description here

On top of this surface map, I would like to add a map of vegetation density such that I obtain something like this (obtained with the software Surfer):

enter image description here

Is it possible to do this with rgl, or for that matter any other package in r or is the only solution to have two maps like in Shane's answer?

Thank you.

Edit:

Following @gsk3's request, here is the code for this map:

library(rgl)

# Read the z (i.e. elevation) dimension from file
z1 = matrix(scan("myfile.txt"),nrow=256, ncol=256, byrow=TRUE)
#create / open x y (i.e. easting and northing coordinates) dimensions 
y=8*(1:ncol(z)) # Each point is 8 m^2
x=8*(1:nrow(z))

# See https://stackoverflow.com/questions/1896419/plotting-a-3d-surface-plot-with-contour-map-overlay-using-r for details of code below
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)

I can't post the elevation code because there are 65536 (i.e. x*y=256*256) points but it is a matrix which looks like this

            [,1]     [,2]     [,3]     [,4]     [,5] 
[1,]    1513.708 1513.971 1514.067 1513.971 1513.875 
[2,]    1513.622 1513.524 1513.578 1513.577 1513.481

and so on. Same for the vegetation density map, which is exactly the same format and for which I have a single value for each x*y point. I hope this makes things a bit clearer...?

<

r rgl
Edit
Report