R has a full library of tools for working with spatial data. This includes tools for both vector and raster data, as well as interfacing with data from other sources (like ArcGIS) and making maps.
These tutorials — which build off Claudia Engel’s excellent GIS in R tutorials — are designed for users with some familiarity with R, but require no knowledge of spatial analysis. If you aren’t used to working with R, you will probably want to spend some little time familiarizing yourself with the language before starting this series. (Here’s a good set of R tutorials if you need them)
Each tutorial is divided into several parts (to be done in sequence), and include a zipped folder of data for exercises. In addition, cheatsheets are provided which may be of help in remembering the various commands you will frequently use. Each tutorial is meant to take ~1.5 hours, not including software installation.
These tutorials have a share-and-share-alike Creative Commons license, so please feel free to use and modify as you see fit. You can find rmarkdown source files on github here.
Command Cheatsheets:
Learning GIS in R involves learning both concepts and vocabulary. Here are some cheatsheets to help with the later.
Tutorial 1: Introduction to Data Types
The aim of Tutorial 1 is to provide users with a solid understanding of how R thinks about spatial data. It covers some material that users will not need to deal with on a day to day basis, but by providing an understanding of the organization of each library, it is my hope they will help users avoid problems, solve problems when they arise, and to know how to identify the sources of problems when they need to ask others for guidance.
Tutorial 1.5: Background on Projections, Coordinate Reference Systems, and Geographic Coordinate Systems
Concepts like “projections” and “coordinate systems” are tricky on their own, and this trickiness is made all the worse by the fact there’s incredible inconsistency in how these terms are used. In this handout, I lay out the two main concepts you need to know, then provide an overview of what different programs and communities actually mean when they use terms like “projection”.
Tutorial 2: Combining Multiple Data Sources
Rarely can the answers we seek be found in a single data-set. Here are a set of tools for combining multiple datasets through methods like spatial joins, distance calculations, etc.
- Part 2.0: Setup
- Part 2.1: Spatial Joins
- Supplementary Doc on lapply and sapply
- Part 2.2: Geometric Manipulations: Buffers, Distances, Intersections, etc.
Tutorial 3: Making Maps
Visualization is central to sharing our results. This tutorial covers the basics of making visually appealing and informative maps in R.
Tutorial 4: Geocoding (Very Short) and Background on APIs
How to convert addresses and location names to latitudes and longitudes from R using the Google Maps API. Also some optional background on what an API is, and how most web APIs work.
Tutorial 5: Spatial Statistics and Surface Interpolation
Libraries for spatial statistics like Ripley’s K, Moran’s I, Spatial Auto-Regressive Lag regressions, Error Auto-Regressive regressions, etc, as well as libraries for surface interpolation via IDW and Kriging.
Tutorial 6: Combining Network Analysis with GIS
This tutorial introduces network analysis concepts, and provides an overview of how to combine a specific type of network analysis — community detection — with GIS to visualize community structures in space.
Tutorial 7: Need more performance?
A brief overview of some tools for getting better performance. For example, tutorial includes an example of how to find the nearest neighbor in one DataFrame for each observation in a second DataFrame without calculating every single distance and taking the minimum.
Other Resources by Other People:
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.