Skip to main content

Spatial Analysis with sf and raster in R

Analyze spatial data using the sf and raster packages.

Start Course for Free
4 Hours15 Videos53 Exercises10,149 Learners4550 XPSpatial Data Track

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

There has never been a better time to use R for spatial analysis! The sf package has made working with vector data in R a breeze and the raster package provides a set of powerful and intuitive tools to work gridded data like satellite imagery. Instead of the painful process of performing your spatial analysis in GIS systems like ArcGIS or QGIS and then shuffling your results into another system for analysis, you can move your entire spatial analysis workflow into R. In this course you will learn why the sf package is rapidly taking over spatial analysis in R. You will read in spatial data, manipulate vectors using the dplyr package and learn how to work with coordinate reference systems. You'll also learn how to perform geoprocessing of vectors including buffering, spatial joins, computing intersections, simplifying and measuring distance. With rasters, you will aggregate, reclassify, crop, mask, and extract. The last chapter of the course is devoted to showing you how to make maps in R with the ggplot2 and tmap packages and performing a fun mini-analysis that brings together all your new skills.

  1. 1

    Vector and Raster Spatial Data in R


    An introduction to import/export, learning the formats and getting to know spatial data. Some discussion of why we're using sf rather than sp.

    Play Chapter Now
    Reading vector and raster data into R
    50 xp
    Reading vector data
    100 xp
    Reading raster data
    100 xp
    Getting to know your vector data
    50 xp
    sf objects are data frames
    100 xp
    Geometry is stored in list-columns
    100 xp
    Extracting geometric information from your vector layers
    100 xp
    First look at plotting vector spatial objects
    100 xp
    Getting to know your raster data
    50 xp
    Learning about your raster objects
    100 xp
    Accessing raster data values
    100 xp
    Plot your raster object
    100 xp
  2. 3

    Conducting spatial analysis with the sf and raster packages

    Now that you have learned about sf and raster objects and have prepared your layers for analysis we can begin conducting true spatial analysis. Both sf and raster have a suite of functions that allow you to do single-layer kinds of analysis like buffering and computing hulls as well as multi-layer operations like intersections, overlaps, masking and clipping.

    Play Chapter Now

In the following tracks

Spatial Data


richieRichie Cotton
Zev Ross Headshot

Zev Ross

President, ZevRoss Spatial Analysis

Zev is the President of ZevRoss Spatial Analysis, a company that focuses on data science, machine learning, and development of data applications with a focus on spatial data. He is the author or co-author of over 40 peer-reviewed publications that focus on public health, spatial analysis and statistics. Zev also runs a popular data science blog and teaches workshops on spatial analysis and machine learning with R.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA