# Lesson 2. Layer a raster dataset over a hillshade using R baseplot to create a beautiful basemap that represents topography

## Learning objectives

After completing this tutorial, you will be able to:

• Overlay 2 rasters in R to create a plot

## What you need

You need R and RStudio to complete this tutorial. Also you should have an earth-analytics directory setup on your computer with a /data directory with it.

# load raster and rgdal libraries for spatial data
library(raster)
library(rgdal)


## Overlay rasters in R

Here, we will cover overlaying rasters on top of a hillshade for nicer looking plots in R. To overlay a raster we will use the add = T argument in the R plot() function. We will use alpha to adjust the transparency of one of our rasters so the terrain hillshade gives the raster texture! Also we will turn off the legend for the hillshade plot as the legend we want to see is the DEM elevation values.

# open raster DTM data
lidar_dem <- raster(x="data/week_03/BLDR_LeeHill/pre-flood/lidar/pre_DTM.tif")

lidar_dem_hill <- raster(x="data/week_03/BLDR_LeeHill/pre-flood/lidar/pre_DTM_hill.tif")

# plot raster data
plot(lidar_dem_hill,
main = "Lidar Digital Elevation Model (DEM)\n overlayed on top of a hillshade",
col = grey(1:100/100),
legend=F)

plot(lidar_dem,
main = "Lidar Digital Elevation Model (DEM)",