Chapter 6 Mapping Raster Data
6.1 Mapping raster elevation data
Now, let's discuss mapping raster type data. Raster data consists of pixels that represent an area on the surface of the earth. The most common raster data used for geospatial applications is elevation (sometimes referred to as a digital elevation model, or DEM). Here we will add a DEM layer to a leaflet map using the
addRasterImage() function. You may specify the color ramp from the Color Brewer palette names, or you may call a vector of colors. Below are two example of using a default color schema from Color Brewer and a color schema developed by calling color names (again,
colors() will output all the color names that R knows).
# Raster with Color Brewer schema leaflet() %>% addTiles() %>% addRasterImage(elevation_projected, colors = "Spectral")
# Raster with color scheme with a vector of color names leaflet() %>% addTiles() %>% addRasterImage(elevation_projected, colors = c("forestgreen","yellow","tan","brown"))