Creating Maps with R

Creating Maps with R

2h 32mIntermediate2022-09-23

Authors

Charlie Joey Hadley

Charlie Joey Hadley

Technology and open data evangelist

Course details

If you need to learn more about creating maps with R, this beginner-friendly course introduces an end-to-end mapping workflow and shows you how to import your data directly from Excel to create both static and interactive maps. Instructor Charlie Joey Hadley explains mapping fundamentals, like geo markers, scatter plots, hexbin maps, cartograms, and more. Charlie walks you through processing GIS data from Excel and working with GIS data formats such as raster, vector, sf, and sp. She demonstrates how to create, label, and transform static maps with ggplot2, then dives into building interactive, mobile-ready maps using Leaflet, an HTML widget package for creating interactive maps with R. Plus, Charlie covers base maps and tiles, projections, the Coordinate Reference System (CRS), and more.

Skills covered

ggplotGISRStatisticsAECProgramming LanguagesData ScienceOpen SourceSoftware DevelopmentDeep Dive (X:Y)

Concepts

Introduction

  • Why create maps with R
  • Base knowledge
  • GitHub repository and exercise files

Mapping Fundamentals

  • How to choose a map
  • Geo marker and scatter plots
  • Geo bubble charts
  • Choropleth - Shaded area maps
  • Hexbin maps or hexagonally binned choropleth
  • Dot density
  • Cartograms - Distorted area maps

Processing GIS Data from Excel

  • Standardize country names with countrycode
  • Join shapefiles with data in Excel files
  • Convert addresses to coordinates with geocoding
  • Challenge - Geolocate all US state capitol buildings
  • Solution - Geolocate all US state capitol buildings

Working with GIS Data Formats

  • GIS data formats - Raster or vector
  • Vector GIS data - sf and sp
  • Work with sf datasets and the tidyverse
  • Challenge - Visualizing continent populations
  • Solution - Visualizing continent populations

Static Maps with ggplot2

  • Use geom sf to visualize geo locations
  • ggplot2 choropleth and continuous data
  • ggplot2 choropleth and discrete data
  • Label maps with ggrepel package
  • Zoom into regions with coords sf()
  • Transform CRS with coord sf()
  • Challenge - Label a geobubble chart of Germany's biggest cities
  • Solution - Label a geobubble chart of Germany's biggest cities
  • Challenge - Visualize state coastline length with choropleth
  • Solution - Visualize state coastline length with choropleth

Interactive Maps with Leaflet

  • The basics of using Leaflet
  • Use Leaflet to visualize geo locations
  • Add labels and pop-ups to Leaflet maps
  • Leaflet choropleth and continuous data
  • Leaflet choropleth and discontinuous data
  • Set a background color with leaflet.extras
  • Challenge - Add pop-up labels to a map of German cities
  • Solution - Add pop-up labels to a map of German cities
  • Challenge - Interactive choropleth of state coastline length
  • Solution - Interactive choropleth of state coastline length

CRS, Projections, and Map Tiles

  • Base maps and tiles
  • What are projections and CRS
  • Geographics vs. projected CRS
  • How to choose CRS and use them with sf

Conclusion

  • What else can you learn about creating maps in R
80,000 Toman