Introduction to Working with Raster Data in R

Creation supported by NEON, Data Carpentry, SESYNC, and iPlant Collaborative
Table of Contents

The tutorials in this series cover how to open, work with and plot raster-format spatial data in R. Additional topics include working with spatial metadata (extent and coordinate reference system), reprojecting spatial data and working with raster time series data.

Data used in this series cover NEON Harvard Forest and San Joaquin Experimental Range field sites and are in GeoTIFF and .csv formats.

Learning Objectives

After completing the series you will:

  • Raster 00
    • Understand what a raster dataset is and its fundamental attributes.
    • Know how to explore raster attributes in R.
    • Be able to import rasters into R using the raster package.
    • Be able to quickly plot a raster file in R.
    • Understand the difference between single- and multi-band rasters.
  • Raster 01
    • Know how to plot a single band raster in R.
    • Know how to layer a raster dataset on top of a hillshade to create an elegant basemap.
  • Raster 02
    • Be able to reproject a raster in R.
  • Raster 03
    • Be able to to perform a subtraction (difference) between two rasters using raster math.
    • Know how to perform a more efficient subtraction (difference) between two rasters using the raster overlay() function in R.
  • Raster 04
    • Know how to identify a single vs. a multi-band raster file.
    • Be able to import multi-band rasters into R using the raster package.
    • Be able to plot multi-band color image rasters in R using plotRGB.
    • Understand what a NoData value is in a raster.
  • Raster 05
    • Understand the format of a time series raster dataset.
    • Know how to work with time series rasters.
    • Be able to efficiently import a set of rasters stored in a single directory.
    • Be able to plot and explore time series raster data using the plot() function in R.
  • Raster 06
    • Be able to assign custom names to bands in a RasterStack for prettier plotting.
    • Understand advanced plotting of rasters using the rasterVis package and levelplot.
  • Raster 07
    • Be able to extract summary pixel values from a raster.
    • Know how to save summary values to a .csv file.
    • Be able to plot summary pixel values using ggplot().
    • Have experience comparing NDVI values between two different sites.

Things You’ll Need To Complete This Series

Setup RStudio

To complete the tutorial series you will need an updated version of R and, preferably, RStudio installed on your computer.

R is a programming language that specializes in statistical computing. It is a powerful tool for exploratory data analysis. To interact with R, we strongly recommend RStudio, an interactive development environment (IDE).

Install R Packages

You can chose to install packages with each lesson or you can download all of the necessary R Packages now.

  • raster: install.packages("raster")
  • rgdal: install.packages("rgdal")
  • rasterVis: install.packages("rasterVis")
  • ggplot2: install.packages("ggplot2")

  • More on Packages in R – Adapted from Software Carpentry.


Working with Raster Data in R Tutorial Series: This tutorial series is part of a Data Carpentry workshop
on using spatio-temporal in R. Other related series include: intro to spatio-temporal data and data management, working with vector data in R, and working with tabular time series data in R.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Find more series
mjones01
Dialog content.