Just documenting using Rayshader to render graphics after watching the creator talk demonstrate it’s capabilities. Usually this will render and can be moved by the end user, but I was having difficulties. So instead I just used a .jpeg image.
library(rayshader)
#Here, I load a map with the raster package.
loadzip = tempfile()
download.file("https://tylermw.com/data/dem_01.tif.zip", loadzip)
localtif = raster::raster(unzip(loadzip, "dem_01.tif"))
unlink(loadzip)
#And convert it to a matrix:
elmat = raster_to_matrix(localtif)
The below function was found on stackoverflow here
#function to plot jpeg files
plot_jpeg = function(path, add=FALSE)
{
require('jpeg')
jpg = readJPEG(path, native=T) # read the file
res = dim(jpg)[2:1] # get the resolution, [x, y]
if (!add) # initialize an empty plot area if add==FALSE
plot(1,1,xlim=c(1,res[1]),ylim=c(1,res[2]),asp=1,type='n',xaxs='i',yaxs='i',xaxt='n',yaxt='n',xlab='',ylab='',bty='n')
rasterImage(jpg,1,1,res[1],res[2])
}
plot_jpeg("rayshader.jpeg")
## Loading required package: jpeg