library(here)
library(tidyverse)
library(stars)
library(sf)
library(tmap)
Reference
Refer to the Plotting Geospatial Data resource and tmap book to help get you started.
Learning Objectives
- Read in spatial objects
- Create map with single spatial object
- Create map with multiple spatial objects
- Use different types of
tmap
plotting formats (e.g.tm_polygons()
,tm_fill()
,tm_dots()
, etc.) - Adjust color palettes
- Include essential map elements (e.g. scale bar & north arrow or graticules)
- Create an interactive map
- Bonus Challenge: Reproduce map using
ggplot2
instead oftmap
Get Started
Let’s load the necessary packages:
And read in the spatial objects for Easter Island (Rapa Nui/Isla de Pascua):
ei_points
: file contains several points on the islandei_elev
: raster with elevation dataei_borders
: polygon with the island outlineei_roads
: lines contains a road network for the island
<- sf::read_sf(here::here("data", "week1", "easter_island", "ei_points.gpkg"))
ei_points <- subset(ei_points, type == "volcano")
volcanoes <- stars::read_stars(here::here("data", "week1", "easter_island", "ei_elev.tif"))
ei_elev <- sf::read_sf(here::here("data", "week1", "easter_island", "ei_border.gpkg"))
ei_borders <- sf::read_sf(here::here("data", "week1", "easter_island", "ei_roads.gpkg")) ei_roads
Now, to meet our learning objectives, your task:
- Create a map of Easter Island
- Create a map of Easter Island and…
- …denote the island’s borders and continuous elevation
- …denote the island’s volcanoes and roads
- …play with the color palette and essential map elements
- Create an interactive map of Easter Island