rayshader - HerbFargus/Wikis GitHub Wiki

Install R:

Windows needs these files:

R:

https://cran.r-project.org/bin/windows/base/

Rtools:

https://cran.r-project.org/bin/windows/Rtools/

Rstudio:

https://www.rstudio.com/products/rstudio/download/

Packages within R:

install.packages("devtools")
install.packages("rgdal")
install.packages("magick")

Install Rayshader:

devtools::install_github("tylermorganwall/rayshader")

Basic Code:

library(rayshader)
library(rgdal)

#Here, I load a map with the raster package.
#Test File to download from here: https://tylermw.com/data/dem_01.tif.zip
localtif = raster::raster("path/to/dem_01.tif")

#And convert it to a matrix:
elmat = raster_to_matrix(localtif)

#We use another one of rayshader's built-in textures:
elmat %>%
 sphere_shade(texture = "desert") %>%
 plot_map()

# you can also add some other variables:
#  add_water(detect_water(elmat), color = "desert") %>%
#  add_shadow(ray_shade(elmat), 0.5) %>%
#  add_shadow(ambient_shade(elmat), 0) %>%