GIS and R prerequisites

GIS basics

Before working with the data layers from BeeSpatial in R, here are some geographic information systems (GIS) terms and concepts that are necessary to understand. For a more in-depth introduction to GIS in R, you may want to look elsewhere on the web.

  • raster: A form of geographic data that represents the landscape as a grid of cells. Grid values can be continuous values, signifying things like elevation, temperature, or spectral information (e.g. color) in a satellite image; or categorical values, signifying thematic classes like land cover.
  • vector: Another form of geographic data that represents specific features on the landscape composed of discrete geometric locations that consist of x and y values. These can be points, lines, or polygons.
  • Cropland Data Layer (CDL): A set of raster datasets produced by the USDA National Agricultural Statistics (NASS) Service and Agricultural Research Service (ARS) that represents annual crop-specific land cover produced from satellite imagery and ground reference data.

Loading necessary packages

There are a number of packages in R that are helpful in working with spatial data. For this workshop we will be using sf and terra. For data wrangling and visualizations we will use dplyr, ggplot2 and tidyterra.

Name Description Link
dplyr Package that provides a ‘grammar’ of data manipulation in R https://dplyr.tidyverse.org/
ggplot2 Package that provides a system for declaratively creating graphics https://ggplot2.tidyverse.org/
sf Package for manipulating 2-D geographic vector data https://r-spatial.github.io/sf/
terra Package for spatial data analysis https://rspatial.github.io/terra/
tidyterra Package for integrating objects from terra with the dplyr and ggplot2 packages https://dieghernan.github.io/tidyterra/

Because some spatial functions have the same names as dplyr functions it is helpful to load the spatial packages last. We can also use the :: to specify the package for function calls.

Unhash (remove the preceding #) and use install.packages for any packages your may not already have installed

# install.packages("dplyr", dependencies = TRUE)
# install.packages("ggplot2", dependencies = TRUE)
# install.packages("sf", dependencies = TRUE)
# install.packages("terra", dependencies = TRUE)
# install.packages("tidyterra", dependencies = TRUE)

library(dplyr)
library(ggplot2)
library(sf)
library(terra)
library(tidyterra)