Week 2: Creating Maps with the Leaflet Package

Stat 431



Time Estimates:
     Videos: 37 min
     Readings: 15 min
     Activities: 60 min
     Check-ins: 3



Extra Resources:

Creating Maps

Maps are fantastic and complicated all at the same time!

Maps are some of the richest visualizations around because they come with data built into them. That is, on top of whatever data you’re going to plot you are also probably going to view terrain, roads, state/country borders, city names or a host of other information that come with our geography.

This implicit richness only adds to challenge of creating a good map. Observe the following recent tweet for a silly example of how maps can be…difficult.

Ah maps…

And there is no shortage of map data visualizations on the web, but all too often this is what we end up with:


Required Video: Introductory Series to Leaflet in R (6 Videos)


Be sure to watch all 6 videos in this series.


Check-In 1: Creating a Base Map


  1. Is running just the leaflet() function enough to produce a map?
  • Yes
  • No
  1. To plot data points on a leaflet map, we should probably use which function?
  • addTiles()
  • addMarkers()
  • addProviderTiles()
  • addPolygons()

Canvas Link     

More on the leaflet package

The leaflet package is actually extremely rich and can basically enable (interactive) map visualizations as complex as you can imagine. Take some time to peruse the site for the leaflet R package:


Required Reading: Leaflet in R



Check-In 2: Exploring Leaflet in R


  1. Briefly explain what choropleths are useful for and how they’re different from the other ways in which leaflet can display data?

  2. What do the names of your plotted data columns have to be?

  • x; y
  • leafletx; leaflety
  • lat/latitude; lon/lng/long/longitude
  • Anything as long as you tell the addMarkers() function correctly
  1. If you were to think of latitude and longitude as coordinates in the cartesian coordinate system, then…
  • latitude is on the horizontal axis and longitude is on the vertical
  • latitude is on the vertical axis and longitude is on the horizontal

Canvas Link     

Practice With Leaflet


Check-In 3: Dissecting the Map


The above map plots data on NASA astronauts!

  1. The graphic for each marker is a little astronaut helmet. How cute! This image was used via…
  • a URL pointing to it on the web.
  • a downloaded image file.
  1. The “popup” argument specifies what you see when you ______, while the “label” argument specifies what you see when you ______.
  • hover; click
  • zoom-in; zoom-out
  • click; hover
  • squint your eyes; look normally

Canvas Link