The package rasterShade is just a wrapper around function in rayshader package. The rasterShade package allows using rayshader algorithm directly on spatial data in form of Raster. The package tries to set "reasonable" default values for parameters in rayshadering algorithm. These default values are based on real world shadows that can be seen in nature.
First you need to install rayshader package from CRAN or GitHub. The description of this package can be found in this great blogpost and in this follow-up.
devtools::install_github("tylermorganwall/rayshader")
Then this package rasterShade can be installed:
devtools::install_github("JanCaha/rasterShade")
Loading the libraries and preparing data:
library(raster)
library(rasterShade)
raster <- raster("digital_surface_model.tif")
Global shading raster:
shadow_raster <- shade_global_date_time(raster,
date = "2018-05-23",
sun_elevation = "noon",
search_distance = 100)
writeRaster(shadow_raster, "equinox_noon.tif", overwrite = TRUE)
Raster shading using lambert method:
shadow_raster <- shade_global_date_time(raster,
only_facing_sun = TRUE,
verbose = TRUE)
writeRaster(shadow_raster, "today_noon_lambert.tif", overwrite = TRUE)
Raster shading using ambient shadows:
shadow_raster <- shade_ambient_date_time(raster,
date = "2018-05-23",
sun_elevation = "noon",
rays_number = 36,
search_distance = 100)
writeRaster(shadow_raster, "equinox_noon_ambient.tif", overwrite = TRUE)