Open-Source Spatial Analytics (R)

In this course, you will learn to work within the free and open-source R environment with a specific focus on working with and analyzing spatial data. We will cover a wide variety of data and spatial data analytics topics, and you will learn how to code in R along the way. This course is designed for someone with some prior GIS knowledge. For example, you should know the basics of working with maps, map projections, and vector and raster data. You should be able to perfrom common spatial analysis tasks and make map layouts. If you do not have a GIS background, I would recommend checking out our Introduction to GIScience class. We do not assume that you have any prior experience with R or with coding. So, don't worry if you haven't developed these skillsets yet. That is a major goal in this course.

Backgound material will be provided using code examples, videos, and presentations. Most of the data will be provided so that you can follow along. We have also provided assignments and a term project. Data for the assignments are provided in the Sequencing and Resources section. This section also includes a suggested sequence for working through the material. Feel free to point out issues or provided suggestions.

This course was produced by West Virginia View ( with support from AmericaView ( This material is based upon work supported by the U.S. Geological Survey under Grant/Cooperative Agreement No. G18AP00077. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the opinions or policies of the U.S. Geological Survey. Mention of trade names or commercial products does not constitute their endorsement by the U.S. Geological Survey.

After completing this course you will be able to:

  1. prepare, manipulate, query, and generally work with data in R
  2. perform data summarization, comparisons, and statistical tests
  3. create quality graphs, map layouts, and interactive web maps to visualize data and findings
  4. present your research, methods, results, and code as web pages to foster reproduceable research
  5. work with spatial data in R
  6. analyze vector and raster data to answer a question with a spatial component
  7. make spatial models and predictions using regression and machine learning
  8. code in the R language at an intermediate level

Last course update: November 11, 2021

  1. Introduction
  2. Set Up R and RStudio
  3. R Language Part I
  4. Data Queries and Manipulation
  5. Working with Strings and Factors
  6. R Language Part II
  7. Data Summarization and Statistics
  8. R Markdown
  9. Graphs with ggplot2 Part I
  10. Graphs with ggplot2 Part II
  11. Tables with gt
  12. Working with Spatial Data
  13. Maps with tmap
  14. Additional Map Examples
  15. Interactive Maps with Leaflet
  16. Vector-Based Spatial Analysis
  17. Raster-Based Spatial Analysis (raster)
  18. Raster-Based Spatial Analysis (terra)
  19. LiDAR and Image Analysis
  20. Machine Learning Background
  21. Regression and Diagnostics
  22. Random Forests in R
  23. Machine Learning with caret
  24. Machine Learning with tidymodels
  1. Sequencing and Resources
  2. A1: Data Queries and Manipulation
  3. A2: Functions and Loops
  4. A3: Data Summarization and Statistics
  5. A4: R Markdown Webpage
  6. A5: Aesthetic Mappings
  7. A6: Graph Design
  8. A7: Table Design
  9. A8: Map Layout Design
  10. A9: Leaflet Interactive Web Map
  11. A10: Vector-Based Spatial Analysis
  12. A11: Raster Analysis (raster)
  13. A12: Raster Analysis (terra)
  14. A13: Image Analysis: Fire Severity
  15. A14: Linear Regression: Fire Severity
  16. A15: Multiple Linear Regression
  17. A16: Slope Failure Prediction
  18. A17: Classification with caret
  19. A18: Regression with caret
  20. A19: Classification with caret and GEOBIA
  21. A20: Classification with tidymodels
  22. Term Project