# Spatial Analysis with sf and raster in R

Analyze spatial data using the sf and raster packages.

Start Course for Free## Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.## 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
### Vector and Raster Spatial Data in R

**Free**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.

Reading vector and raster data into R50 xpReading vector data100 xpReading raster data100 xpGetting to know your vector data50 xpsf objects are data frames100 xpGeometry is stored in list-columns100 xpExtracting geometric information from your vector layers100 xpFirst look at plotting vector spatial objects100 xpGetting to know your raster data50 xpLearning about your raster objects100 xpAccessing raster data values100 xpPlot your raster object100 xp - 2
### Preparing layers for spatial analysis

In this lesson you will learn how to prepare layers so that you can conduct spatial analysis. This includes ensuring that the layers all share the same coordinate reference system.

A quick refresher on the coordinate reference system50 xpVector and raster coordinate systems100 xpTransform your layers to a common CRS100 xpPlot vector and raster together100 xpManipulating vector layers with dplyr50 xpDropping geometry from a data frame100 xpJoin spatial and non-spatial data100 xpSimplify the neighborhood boundaries100 xpConverting sf objects into sp objects and coordinates50 xpConverting sf objects to sp objects100 xpConverting to and from coordinates100 xpManipulating raster layers50 xpChange the raster grid cell size using aggregate100 xpChange values and handle missing values in rasters100 xp - 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.

Buffers and centroids50 xpBuffer layers100 xpCompute polygon centroids100 xpBounding boxes, dissolve features and create a convex hull50 xpCreate a bounding box around vector data100 xpDissolve multiple features into one100 xpCompute a convex hull around vectors100 xpMulti-layer geoprocessing and relationships50 xpSpatial joins100 xpSpatial relationships100 xpMeasuring distance between features100 xpGeoprocessing with rasters50 xpLimit rasters to focus areas100 xpCrop a raster based on another spatial object100 xpExtract raster values by location100 xpRaster math with overlay100 xp - 4
### Combine your new skills into a mini-analysis

You are now ready to combine your skills into a mini-analysis. The goal is to evaluate whether the average canopy density by NYC neighborhood is correlated with the number of trees by neighborhood and to create a nice plot of the result.

Compute tree density and average tree canopy by neighborhood50 xpCompute tree density by neighborhood (I)100 xpCompute tree density by neighborhood (II)100 xpCompute average tree canopy by neighborhood100 xpFirst look at results with ggplot250 xpCreate plots using ggplot2100 xpCreate a map using ggplot2100 xpCreate final, polished maps with tmap50 xpCreate a map using tmap100 xpUse tmap to create a final pretty map100 xpWrap-up video50 xp

#### 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.

## What do other learners have to say?

## Join over 10 million learners and start Spatial Analysis with sf and raster in R today!

## Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.