From the course: Creating Maps with R

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Solution: Visualize state coastline length with choropleth

Solution: Visualize state coastline length with choropleth

From the course: Creating Maps with R

Solution: Visualize state coastline length with choropleth

(upbeat music) - [Instructor] Okay, so let's start solving this challenge by opening the script in the 04_10b project. Going to load my packages on lines one through five. Line seven through 12, we're going to obtain shape files for the contiguous United States. Line 15 we'll read in a dataset. Lines 17 through 19, we're going to join those two data sets together. I just want to print this to the console so you can see it's an SF object. And there's a column called KM of coastline that tells us how many kilometers of coastline each state has. And notice many of the states have NA values. So I've started our data visualization off, on lines 22 through 24. But what we want to do is turn this into an actual choropleth, by varying the color of each of the regions. So I'm going to add a comma, AES, fill is equal to KM of coastline. And what ggplot2 does, is it sees our numeric column and it creates a default continuous…

Contents