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
  1. Introduction and Setup
  2. R Language Part I
  3. Data Queries and Manipulation with dplyr
  4. Working with Strings and Factors
  5. R Language Part II
  6. Data Summarization and Statistics
  7. R Markdown
  8. Graphs with ggplot2 Part I
  9. Graphs with ggplot2 Part II
  10. Working with Spatial Data in R
  11. Maps with tmap
  12. Additional Map Examples
  13. Interactive Maps with Leaflet
  14. Vector-Based Spatial Analysis
  15. Raster-Based Spatial Analysis
  16. LiDAR and Image Analysis
  17. Machine Learning Background
  18. Regression and Diagnostics
  19. Random Forests in R
  20. Machine Learning with caret
  21. Example Leaflet
  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: Map Layout Design
  9. A8: Leaflet Interactive Web Map
  10. A9: Vector-Based Spatial Analysis
  11. A10: Conservative and Liberal Raster Models
  12. A11: Linear Regression
  13. A12: Regression, GWR, and Diagnostics
  14. A13: Probabilistic Prediction with RF
  15. A14: Classification with caret
  16. A15: Regression with caret
  17. A16: Classification with caret and GEOBIA
  18. Term Project