Hillshade effects | Dr. Dominic Royé

Hillshade effects | Dr. Dominic Royé

Dr. Dominic Royé
2022-07-20 8 min read gis , R , R:intermediate , visualization
It is very common to see relief maps with shadow effects, also known as ‘hillshade’, which generates visual depth. How can we create these effects in R and how to include them in ggplot2?
Packages
Collection of packages (visualization, manipulation): ggplot2, dplyr, purrr, etc.
sf
Simple Feature: import, export and manipulate vector data
elevatr
Access to elevation data from various APIs
terra
Import, export and manipulate raster ({raster} successor package)
whitebox
An R interface to the ‘WhiteboxTools’ library, which is an advanced geospatial data analysis platform
tidyterra
Helper functions for working with {terra}
giscoR
Administrative boundaries of the world
ggnewscale
Extension for ggplot2 of multiple ‘scales’
# install the packages if necessary if(!require("tidyverse")) install.packages("tidyverse") if(!require("sf")) install.packages("sf") if(!require("elevatr")) install.packages("elevatr") if(!require("terra")) install.packages("terra") if(!require("whitebox")) install.packages("whitebox") if(!require("tidyterra")) install.packages("tidyterra") if(!require("giscoR")) install.packages("giscoR") if(!require("ggnewscale")) install.packages("ggnewscale") # packages library(sf) library(elevatr) library(tidyverse) library(terra) library(whitebox) library(ggnewscale) library(tidyterra) library(giscoR) library(units)
Data
As an area of interest, we use Switzerland in this example. Except for lake boundaries download , the necessary data is obtained through APIs using different packages. For example, the giscoR package allows you to get country boundaries with different resolutions.
suiz

Images Powered by Shutterstock